24

I have searched this problem all over the web and none of them seem to give me any resolution. I have a simple script to just display the map of South Africa.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" /> <title>Map Test</title> <script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script> <style> #map-canvas { height: 300px; width: 980px; margin: 0; padding: 0; margin-top: 10px; } </style> </head> <body> <div id="map-canvas" class="map_canvas"></div> <script type="text/javascript"> function initialize() { var mapOptions = { center: new google.maps.LatLng(-29.09958,26.18434), zoom: 5, mapTypeControlOptions: { position: google.maps.ControlPosition.TOP_LEFT } }; map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions); } google.maps.event.addDomListener(window, 'load', initialize); </script> </body> </html> 

But I keep on getting the same error over and over. I have even tried on a different server.

enter image description here

Please help

2
  • I could not replicate this issue using Chrome 44 ~ 45. I even tried Firefox and there's no error. Commented Sep 21, 2015 at 9:19
  • @KimHonoridez, the issue does not seem to affect Chrome. The error is intermittent in Firefox 41.0.1. Commented Oct 14, 2015 at 14:05

3 Answers 3

48

I've also seen this error often in the last days, there seems to be an issue with the experimental API-version.

Load the release-version instead(basically you should always load the release-version in production)

<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script> 
Sign up to request clarification or add additional context in comments.

6 Comments

I am surprised that Google serves the experimental (ie. unstable) version by default. However, that is often the case: "If you do not explicitly specify a version, you will receive the experimental version by default. Google Maps API for Work customers who specify a client ID will receive the release version by default." (From developers.google.com/maps/documentation/javascript/versions)
The answer will load the latest "release" version of the v3 API. For some applications, it may be more appropriate to request a specific version (ex. 3.21). See Google's "Best Practices" for more guidance: developers.google.com/maps/documentation/javascript/…
@Dr.Molle, "the sensor parameter is no longer required.": developers.google.com/maps/documentation/javascript/…
Thanks a ton. This problem was causing Firebug to be extremely slow and regularly freezing - making debugging a nightmare. Using "v=3" fixed that.
MAN! i've going craze with this... i've been using the same code for over a year, and suddenly new API keys wouldn't work.
|
1

Google Maps started to through errors when loading the script and on touch events. I'm using it for a cordova application on Android and iOS.enter image description here

These are the errors I get but changing the load version didn't solve it.

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=MYKEY&v=3.21&libraries=geometry,places"></script> 

2 Comments

I've just realised I was loading GMaps async when the device was going online, and there I had the incorrect URL. Here you go, my Saturday gone in me being stupid.
Good job in solving it and thanks for posting your findings. Always good to help others
1

Version 3.30+ is affected of this problem if there is a global var called Map.

ex:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOURKEYHERE&v=3&callback=init" async defer></script> <script type="text/javascript"> function init() { Map.go(); } var Map = { go: function() { console.log("start engine"); } }; </script> 

We got this error:

TypeError: a.prototype is undefined

Renaming window.Map then everything goes fine.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.