File tree Expand file tree Collapse file tree
Samples/Map/Map style options Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343 //subscriptionKey: '[YOUR_AZURE_MAPS_KEY]'
4444 }
4545 } ) ;
46+
47+ //Add events to update the map-info panel.
48+ map . events . add ( "dragend" , ( ) => updateState ( ) ) ;
49+ map . events . add ( "zoomend" , ( ) => updateState ( ) ) ;
4650
4751 //Wait until the map resources are ready.
4852 map . events . add ( 'ready' , function ( ) {
4953 defaultOptions = map . getStyle ( ) ;
5054
5155 //Update the map with the options in the input fields.
5256 updateStyles ( ) ;
57+ updateState ( ) ;
5358 } ) ;
5459
5560 new ClipboardJS ( '.copyBtn' ) ;
152157 document . getElementById ( tabName ) . style . display = "block" ;
153158 elm . className += " active" ;
154159 }
160+
161+ function updateState ( ) {
162+ var camera = map . getCamera ( ) ;
163+ document . getElementById ( "map-info" ) . innerText =
164+ `Zoom: ${ camera . zoom . toFixed ( 1 ) } / ` +
165+ `Lat: ${ camera . center [ 1 ] . toFixed ( 5 ) } / ` +
166+ `Lng: ${ camera . center [ 0 ] . toFixed ( 5 ) } ` ;
167+ }
155168 </ script >
156169 < style >
157170 # myMap {
162175 float : left;
163176 }
164177
178+ # panel {
179+ position : absolute;
180+ top : 14px ;
181+ left : 378px ;
182+ padding : 10px ;
183+ border-radius : 5px ;
184+ background-color : white;
185+ }
186+
165187 . sidePanel {
166188 width : 325px ;
167189 height : 580px ;
372394 </ fieldset >
373395
374396 < div id ="myMap "> </ div >
397+ < div id ="panel ">
398+ < div id ="map-info "> </ div >
399+ </ div >
375400</ body >
376401</ html >
You can’t perform that action at this time.
0 commit comments