一切正常,突然出现错误Cannot read property 'entries' of undefined
它可能是? (包括googlemaps api)
Uncaught TypeError: Cannot read property 'entries' of undefined
at js?key=<API_KEY>&callback=Map.init:105
Map.init
Map.init = function (id) {
id = id || 'map';
map = new google.maps.Map(document.getElementById(id), {
center: {lat: 46.409998, lng: 30.710000},
scrollwheel: true,
zoom: this.address ? 20 : 12
});
infoWindow = new google.maps.InfoWindow();
map.addListener('zoom_changed', function () {
var zoom = map.getZoom();
if (zoom > zoomShowPoints && !pointsVisibility) {
pointsVisibility = true;
points.forEach(function (item) {
item.setVisible(pointsVisibility);
});
} else if (zoom <= zoomShowPoints && pointsVisibility) {
pointsVisibility = false;
points.forEach(function (item) {
item.setVisible(pointsVisibility);
});
}
});
getUsers();
};
答案 0 :(得分:9)
Google于2017年11月更改了他们的Maps API脚本。他们开始使用全局变量Map来破坏我们的网站。在我们的脚本中将Map变量重命名为OurMap修复了这个问题。
var Map;
更改为;
var OurMap;
答案 1 :(得分:3)
通过添加版本参数
解决了这个问题https://maps.googleapis.com/maps/api/js的 V = 3 强>&安培;键=安培;回调= Map.init