Set Popup
Attach a popup to a marker instance<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Set Popup</title> <meta name="viewport" content="width=device-width, initial-scale=1" /> <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; padding: 0; } html, body, #map { height: 100%; } #marker { background-image: url('https://developer.trimblemaps.com/maps-sdk/assets/washington-monument.jpg'); background-size: cover; width: 50px; height: 50px; border-radius: 50%; cursor: pointer; } .trimblemaps-popup { max-width: 200px; } </style> </head> <body> <div id="map"></div> <script> const monument = [-77.0353, 38.8895]; TrimbleMaps.setAPIKey('YOUR_API_KEY_HERE'); const map = new TrimbleMaps.Map({ container: 'map', style: TrimbleMaps.Common.Style.TRANSPORTATION, center: monument, zoom: 15, }); // create the popup const popup = new TrimbleMaps.Popup({offset: 25}).setText( 'Construction on the Washington Monument began in 1848.' ); // create DOM element for the marker const el = document.createElement('div'); el.id = 'marker'; // create the marker new TrimbleMaps.Marker({element: el}) .setLngLat(monument) .setPopup(popup) // sets a popup on this marker .addTo(map); </script> </body> </html>
Set Popup
<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Set Popup</title> <meta name="viewport" content="width=device-width, initial-scale=1" /> <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; padding: 0; } html, body, #map { height: 100%; } #marker { background-image: url('https://developer.trimblemaps.com/maps-sdk/assets/washington-monument.jpg'); background-size: cover; width: 50px; height: 50px; border-radius: 50%; cursor: pointer; } .trimblemaps-popup { max-width: 200px; } </style> </head> <body> <div id="map"></div> <script> const monument = [-77.0353, 38.8895]; TrimbleMaps.setAPIKey('YOUR_API_KEY_HERE'); const map = new TrimbleMaps.Map({ container: 'map', style: TrimbleMaps.Common.Style.TRANSPORTATION, center: monument, zoom: 15, }); // create the popup const popup = new TrimbleMaps.Popup({offset: 25}).setText( 'Construction on the Washington Monument began in 1848.' ); // create DOM element for the marker const el = document.createElement('div'); el.id = 'marker'; // create the marker new TrimbleMaps.Marker({element: el}) .setLngLat(monument) .setPopup(popup) // sets a popup on this marker .addTo(map); </script> </body> </html>