We are including the Google Maps API V3 in our internal systems with the below code:
script src="=&libraries=places,geometry"
This was working until a few hours ago (9am AEST) now in the console all that's returned is:
Uncaught TypeError: b.has is not a function from .js
Is anyone else facing the same problem?
How can I fix it when the code is included from Google's servers?
We are including the Google Maps API V3 in our internal systems with the below code:
script src="https://maps.googleapis.com/maps/api/js?key=&libraries=places,geometry"
This was working until a few hours ago (9am AEST) now in the console all that's returned is:
Uncaught TypeError: b.has is not a function from https://maps.googleapis.com/maps-api-v3/api/js/35/3/map.js
Is anyone else facing the same problem?
How can I fix it when the code is included from Google's servers?
Share Improve this question asked Nov 28, 2018 at 2:25 JRT2018JRT2018 831 silver badge4 bronze badges 2- Please provide a minimal reproducible example that demonstrates your issue (preferably a StackOverflow code snippet). – geocodezip Commented Nov 28, 2018 at 2:35
- 2 Maybe try a different (older/more stable) version – geocodezip Commented Nov 28, 2018 at 2:54
4 Answers
Reset to default 10Had the same problem, using an older version fixed it for now:
https://maps.googleapis.com/maps/api/js?v=quarterly&key=API_KEY
Long time fix - You probably overwrote the native window.Map, see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Map
We have the same problem here. We had a link to the last version : https://maps.googleapis.com/maps/api/js?key=...
If we force the version to 3.34 it does the trick : https://maps.googleapis.com/maps/api/js?v=3.34&key=
Version 3.35 is not working. Google has replaced a function used with maps (hashmaps, not graphic maps) which is used to search for a key. hasOwnProperty(b, c) --> b.has(c)
Problem is that "b" does not have the function "has".
I do not have much more information at this point. We are continuing the investigation.
Good luck everyone.
Regards Vincent
Edit : OK, now I do understand what happened. Somewhere in our map, we are re-defining the prototype "Map". This protoype does not contain the method "has" and maybe "set" too (that was the case for us). You have to search for something like "Map.prototype." in jour JS files. This will give you the hint for where you have to correct your JS. If you can't suppress this prototype, you will have to redefine the missing methods. For example, we had the following prototype :
function Map(){
this.obj = {};
this.count = 0;
}
We had to complete this prototype with the following methods :
Map.prototype.has=function(key){
return this.obj[key] !== undefined;
}
Map.prototype.set = function(key, value){
var oldValue = this.obj[key];
if(oldValue == undefined){
this.count++;
}
this.obj[key] = value;
return oldValue;
}
With this correction, version 3.35 of GoogleMaps JS is working.
I hope it helps.
Regards, Vincent
Same problem but with a different error that suddenly appeared:
map.js:56 Uncaught TypeError: this.j.keys is not a function
No problems when forcing the version to be 3.34 but 3.35 wouldn't load the map or markers.
After of course hours of trying to figure out the issue, renaming a js class so it was no longer called Map fixed it.
Similar thing. Static mature code in high-traffic app. Working for 8+ years. Until this morning. Turned out we had been using a reserved ID claimed by the GMap API for one of our internal object instances ("Map"). Have no idea why it decided today was the day to blow. We were linking in older version (3.29) of the API. Something clearly changed on the Google end of things.