Skip to main content
Question

Embed Google Maps in Form

  • July 17, 2019
  • 0 replies
  • 77 views

Does anyone know how to do this?

I can do a static image using:

"<img src= " &
"https://maps.googleapis.com/maps/api/staticmap?" & "center=" & URLEncode([Address) & "&zoom=" & [zoom] & "&size=" & [width] & "x" & [height] & "&maptype=" & [type] & "&format=" & [format] & "&markers=color:" &[pin color] & "%7Clabel:" & [pin label] & "%7C" & URLEncode([Address]) &  "&key=APIKEY" & ">" 

but I was trying to do this with a interactive map box or something using this from Google's site:

<!DOCTYPE html>
<html>
  <head>
    <title>Simple Map</title>
    <meta name="viewport" content="initial-scale=1.0">
    <meta charset="utf-8">
    <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 100%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <div id="map"></div>
    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: -34.397, lng: 150.644},
          zoom: 8
        });
      }
    </script>
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
    async defer></script>
  </body> </html>



I tried putting this in a code page and calling to it using the iol method, but it doesn't show anything. Anyone have any ideas?

AdamKeever1
Forum|alt.badge.img+2
  • Registered
  • July 17, 2019
When i put the code from the Google site into a code page and view it, I get these errors in the console:



You need to get an API key and put it in the script:



You will also need to enable the Google maps JavaScript API. Once you do these two things you should be good to go: