Add globe control
Turn your map view into a 3D globe by adding a globe control.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<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%;
background: hsl(0, 0%, 2%);
}
</style>
</head>
<body>
<div id="map"></div>
<script>
const map = new smartmapsgl.Map({
apiKey: 'INSERT API-KEY',
container: 'map',
zoom: 2,
center: [13.180343, 35.775],
minZoom: 1,
maxPitch: 85,
hash: true,
style: smartmapsgl.MapStyle.AUTO
});
map.addControl(new smartmapsgl.GlobeControl());
map.on('style.load', () => {
map.setProjection({
type: 'globe' // Set projection to globe
});
});
</script>
</body>
</html>