Add a scale control
Add a scale bar to display distances on the map.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.smartmaps.cloud/packages/smartmaps/smartmaps-gl/v2/umd/smartmaps-gl.min.js"></script>
<style>
html,
body {
height: 100vh;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
const map = new smartmapsgl.Map({
apiKey: "INSERT API-KEY",
container: "map",
center: [11.39085, 47.27574],
zoom: 2,
style: smartmapsgl.MapStyle.AUTO
});
// Add scale control to the map
map.addControl(new smartmapsgl.ScaleControl(), 'bottom-right');
</script>
</body>
</html>