Sadha

Add Two Markers on Google Maps

Sep 6th, 2021 (edited)
1,296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <style>
  5.        /* Set the size of the div element that contains the map */
  6.       #map {
  7.         height: 400px;
  8.         width: 600px;
  9.        }
  10.     </style>
  11.   </head>
  12.   <body>
  13.     <!--The div elements for the map and message -->
  14.     <div id="map"></div>
  15.     <div id="msg"></div>
  16.     <script>
  17. // Initialize and add the map
  18. var map;
  19. function initMap() {
  20.   // The map, centered on Central Park
  21.   const center = {lat: 40.774102, lng: -73.971734};
  22.   const options = {zoom: 15, scaleControl: true, center: center};
  23.   map = new google.maps.Map(
  24.       document.getElementById('map'), options);
  25.   // Locations of landmarks
  26.   const dakota = {lat: 40.7767644, lng: -73.9761399};
  27.   const frick = {lat: 40.771209, lng: -73.9673991};
  28.   // The markers for The Dakota and The Frick Collection
  29.   var mk1 = new google.maps.Marker({position: dakota, map: map});
  30.   var mk2 = new google.maps.Marker({position: frick, map: map});
  31. }
  32.     </script>
  33.     <!--Load the API from the specified URL -- remember to replace YOUR_API_KEY-->
  34.     <script async defer
  35.    src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
  36.     </script>
  37.   </body>
  38. </html>
Add Comment
Please, Sign In to add comment