NyteOwlDave

Embed Google Map

Feb 16th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.09 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <meta charset="utf-8">
  5.     <title>Google Maps example</title>
  6.  
  7.     <script type="text/javascript" src="https://maps.google.com/maps/api/js?key=AIzaSyDDuGt0E5IEGkcE6ZfrKfUtE9Ko_de66pA"></script>
  8.     <script>
  9.     if("geolocation" in navigator) {
  10.       navigator.geolocation.getCurrentPosition(function(position) {
  11.         var latlng = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
  12.         var myOptions = {
  13.           zoom: 8,
  14.           center: latlng,
  15.           mapTypeId: google.maps.MapTypeId.TERRAIN,
  16.           disableDefaultUI: true
  17.         }
  18.         var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  19.       });
  20.     } else {
  21.       var para = document.createElement('p');
  22.       para.textContent = 'Argh, no geolocation!';
  23.       document.body.appendChild(para);
  24.     }
  25.     </script>
  26.     <style>
  27.       #map_canvas {
  28.         width: 600px;
  29.         height: 600px;
  30.       }
  31.     </style>
  32.   </head>
  33.   <body>
  34.     <h1>Simple maps example</h1>
  35.     <div id="map_canvas"></div>
  36.   </body>
  37. </html>
Add Comment
Please, Sign In to add comment