简体   繁体   English

Google Maps Uncaught TypeError:b.has不是函数

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

We are including the Google Maps API V3 in our internal systems with the below code: 我们在内部系统中包含Google Maps API V3,代码如下:

script src="https://maps.googleapis.com/maps/api/js?key=&libraries=places,geometry" 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: 直到几个小时前(澳大利亚东部标准时间上午9点)现在在控制台中工作,所有返回的是:

Uncaught TypeError: b.has is not a function from https://maps.googleapis.com/maps-api-v3/api/js/35/3/map.js 未捕获的TypeError:b.has不是来自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? 当代码包含在Google服务器中时,我该如何解决?

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 长时间修复 - 你可能已经覆盖了原生窗口。地图,请参阅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= ... 我们有上一个版本的链接: https//maps.googleapis.com/maps/api/jskey = ...

If we force the version to 3.34 it does the trick : https://maps.googleapis.com/maps/api/js?v=3.34&key= 如果我们强制版本为3.34就可以解决问题: https//maps.googleapis.com/maps/api/js?v = 3.34&key =

Version 3.35 is not working. 版本3.35无法正常工作。 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) hasOwnProperty(b,c) - > b.has(c)

Problem is that "b" does not have the function "has". 问题是“b”没有“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). 这个原型不包含“has”方法,也可能“设置”(对我们来说就是这种情况)。 You have to search for something like "Map.prototype." 你必须搜索“Map.prototype”之类的东西。 in jour JS files. 在jour JS文件中。 This will give you the hint for where you have to correct your JS. 这将为您提供纠正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. 通过此更正,GoogleMaps JS的3.35版正在运行。

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 map.js:56未捕获TypeError:this.j.keys不是函数

No problems when forcing the version to be 3.34 but 3.35 wouldn't load the map or markers. 强制版本为3.34但3.35不会加载地图或标记时没有问题。

After of course hours of trying to figure out the issue, renaming a js class so it was no longer called Map fixed it. 在尝试找出问题的几个小时后,重命名一个js类,所以它不再被称为Map修复它。

Similar thing. 类似的事情。 Static mature code in high-traffic app. 高流量应用中的静态成熟代码。 Working for 8+ years. 工作8年以上。 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"). 事实证明,我们一直在使用GMap API声明的保留ID用于我们的一个内部对象实例(“Map”)。 Have no idea why it decided today was the day to blow. 不知道为什么今天决定是吹的日子。 We were linking in older version (3.29) of the API. 我们在API的旧版本(3.29)中进行了链接。 Something clearly changed on the Google end of things. 谷歌的一切都明显改变了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的TypeError:对象不是Google Maps上的函数 - Uncaught TypeError: object is not a function on Google Maps 未捕获的TypeError:google.maps.StamenMapType不是函数 - Uncaught TypeError: google.maps.StamenMapType is not a function Google地图-未捕获的TypeError - Google maps - Uncaught TypeError 单击表格中的行时出现新的 Google 图表错误。 Uncaught TypeError: b.split is not a function -- 已经工作了好几年 - New Google Charts Error when clicking on row in table. Uncaught TypeError: b.split is not a function -- Has been working for several years 未捕获的TypeError:对象函数(a,b){返回新的e.fn.init(a,b,h)}没有方法&#39;widget&#39; - Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'widget' 将 google.maps.latLng 对象添加到列表会导致 [Uncaught TypeError: google.maps.latLng is not a function] - Adding google.maps.latLng objects to list causes [Uncaught TypeError: google.maps.latLng is not a function] 未捕获的TypeError:b.replace不是函数 - Uncaught TypeError: b.replace is not a function 使用AJAX的Google Maps InfoWindow - “Uncaught TypeError:Object# <tg> 没有方法&#39;O&#39;“错误 - Google Maps InfoWindow with AJAX - “Uncaught TypeError: Object #<tg> has no method 'O'” error 未捕获的类型错误:google.maps.infoWindow 不是构造函数 - Uncaught TypeError: google.maps.infoWindow is not a constructor 未捕获的类型错误:b.get 不是函数 - Uncaught TypeError: b.get is not a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM