0

I'm trying to call / load GoogleMap api in a javaScript file

    jQuery(function($) {
    // Asynchronously Load the map API 
    var script = document.createElement('script');
    script.src = "https://maps.googleapis.com/maps/api/js?
key=YOUR_API_KEY&callback=initMap";
    document.body.appendChild(script);
    });

I get the error message "Google Maps API error: MissingKeyMapError"

I found this code using the tutorial here > https://www.youtube.com/watch?v=P6wFYOtXwCQ&t=1s

Benix
  • 15
  • 4
  • 3
    Possible duplicate of [ERROR: Google Maps API error: MissingKeyMapError](https://stackoverflow.com/questions/37991340/error-google-maps-api-error-missingkeymaperror) – Roman Koliada Nov 30 '17 at 14:09

1 Answers1

0

You haven't added the API key: https://developers.google.com/maps/documentation/javascript/get-api-key

This is needed to authenticate your application being the unique consumer of the API (only your application can use it...generally).

Just in case you need more information on how API keys work, this is a great resource: https://cloud.google.com/endpoints/docs/openapi/when-why-api-key

script.src = "https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap";

Where it says YOUR_API_KEY add the key.

jburtondev
  • 2,827
  • 1
  • 14
  • 20