Search code examples
javascripthtmlgoogle-maps

Google Map API won't work... (HTML website)


I've completed a HTML website on my own domain and everything works fine.

However, when uploading it to my customers domain (a domain that has been newly registered) the Google map doesn't work and I have an error relating to Google API (MissingKeyMapError to be specific).

Following tips from the internet I have generated an API key but I cannot see where to enter the API key - in my index.html file or script.js? If you would would like to see the websites please let me know and I will share the URL's.

I've spent two days solid trying to fix this and can't see how to resolve.

I hope I have been specific enough. I'd appreciate any help with this.


Solution

  • The key goes in this line:

    <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script> 
    

    (and you can remove the sensor=false)

    <script src="http://maps.google.com/maps/api/js?key=YOUR_API_KEY" type="text/javascript"></script>