Skip to main content

Vector Source

Display a vector source on the map


<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="https://maps-sdk.trimblemaps.com/v4/trimblemaps-4.2.3.css">
        <script src="https://maps-sdk.trimblemaps.com/v4/trimblemaps-4.2.3.js"></script>
        <style>
            body {
                margin: 0;
            }
            html,body,#map {
                height: 100%;
            }
        </style>
    </head>
    <body>
        <div id="map"></div>

        <script>
            TrimbleMaps.setAPIKey('YOUR_API_KEY_HERE');
            const map = new TrimbleMaps.Map({
              container: 'map',
              style: TrimbleMaps.Common.Style.TRANSPORTATION,
              zoom: 13,
              center: [-122.447303, 37.753574],
     });

      map.on('load', () => {
        map.addSource('contours', {
          type: 'vector',
          url: 'https://api.maptiler.com/tiles/contours/tiles.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL',
        });
        map.addLayer({
          id: 'terrain-data',
          type: 'line',
          source: 'contours',
          'source-layer': 'contour',
          layout: {
            'line-join': 'round',
            'line-cap': 'round',
          },
          paint: {
            'line-color': '#ff69b4',
            'line-width': 1,
          },
        });
      });
        </script>
    </body>
</html>

Last updated June 26, 2025.