Skip to content

Commit 5dd5152

Browse files
committed
Update sample to include zoom level info
1 parent ad771d4 commit 5dd5152

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎Samples/Map/Map style options/Map style options.html‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,18 @@
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');
@@ -152,6 +157,14 @@
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 {
@@ -162,6 +175,15 @@
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;
@@ -372,5 +394,8 @@
372394
</fieldset>
373395

374396
<div id="myMap"></div>
397+
<div id="panel">
398+
<div id="map-info"></div>
399+
</div>
375400
</body>
376401
</html>

0 commit comments

Comments
 (0)