Google Maps Uncaught TypeError: b.has is not a function

Had 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