Skip to content

Add a navigation control

Add zoom and rotation controls to your 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: 6,
                style: smartmapsgl.MapStyle.AUTO
            });

            // Add zoom and rotation controls to the map.
            map.addControl(new smartmapsgl.NavigationControl({
                visualizePitch: true, 
                showZoom: true,
                showCompass: true
            }
            ));
        </script>
    </body>
</html>