Custom Layers

Add your own layers to display custom data. Learn more about Map Layers.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <link rel="stylesheet" href="https://maps-sdk.trimblemaps.com/v3/trimblemaps-3.0.0.css" />
        <script src="https://maps-sdk.trimblemaps.com/v3/trimblemaps-3.0.0.js"></script>
        <style>
            body { margin: 0; padding: 0; }

            #map {
                position: absolute;
                top: 0;
                bottom: 0;
                width: 100%;
            }
        </style>
    </head>
    <body>
        <div id="map"></div>

        <script>
            TrimbleMaps.APIKey = 'YOUR_API_KEY_HERE';
            const map = new TrimbleMaps.Map({
              container: 'map', // container id
                style: TrimbleMaps.Common.Style.TRANSPORTATION, // hosted style id
                center: [-77.38, 39], // starting position
                zoom: 9 // starting zoom
            });
            var point = {
                type: 'FeatureCollection',
                features: [
                    {
                        type: 'Feature',
                        properties: {},
                        geometry: {
                            type: 'Point',
                            coordinates: [-77.38, 39]
                        }
                    }
                ]
            };
            // Wait for the map to load before adding layers and data sources
            map.on('load', function () {
                map.addSource('point', {
                    type: 'geojson',
                    data: point
                });
                map.addLayer({
                    'id': 'point',
                    'source': 'point',
                    'type': 'circle',
                    'paint': {
                    'circle-color': "blue",
                    'circle-radius': 10
                    }
                });
            });

        </script>
    </body>
</html>
Last updated August 12, 2021.