GeoJSON Point
Add a point to the map using GeoJSON.<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="stylesheet" href="https://maps-sdk.trimblemaps.com/v3/trimblemaps-3.21.0.css" /> <script src="https://maps-sdk.trimblemaps.com/v3/trimblemaps-3.21.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: [-74.6, 40.36], // starting position zoom: 9 // starting zoom }); // This data can be hard-coded, loaded from a file, or pulled from a service const geoJsonData = { type: 'geojson', data: { type: 'FeatureCollection', features: [{ type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: [ -74.60018, 40.36144 ] } }] } }; // Wait for the map to load before adding layers and data sources map.on('load', function() { // Add GeoJSON data source to the map map.addSource('hqSource', geoJsonData); // Add a layer to draw circles for each point in the data source map.addLayer({ id: 'hqPoints', type: 'circle', source: 'hqSource', paint: { 'circle-radius': 12, 'circle-color': '#33E', 'circle-stroke-color': '#FFF', 'circle-stroke-width': 4 } }); }); </script> </body> </html>
GeoJSON Point
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="stylesheet" href="https://maps-sdk.trimblemaps.com/v3/trimblemaps-3.21.0.css" /> <script src="https://maps-sdk.trimblemaps.com/v3/trimblemaps-3.21.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: [-74.6, 40.36], // starting position zoom: 9 // starting zoom }); // This data can be hard-coded, loaded from a file, or pulled from a service const geoJsonData = { type: 'geojson', data: { type: 'FeatureCollection', features: [{ type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: [ -74.60018, 40.36144 ] } }] } }; // Wait for the map to load before adding layers and data sources map.on('load', function() { // Add GeoJSON data source to the map map.addSource('hqSource', geoJsonData); // Add a layer to draw circles for each point in the data source map.addLayer({ id: 'hqPoints', type: 'circle', source: 'hqSource', paint: { 'circle-radius': 12, 'circle-color': '#33E', 'circle-stroke-color': '#FFF', 'circle-stroke-width': 4 } }); }); </script> </body> </html>