Арс*_*рян -5 javascript google-maps
一切正常,突然之间出现了错误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();
};
Run Code Online (Sandbox Code Playgroud)
Google于2017年11月更改了他们的Maps API脚本.他们开始使用全局变量Map来破坏我们的网站.在我们的脚本中将Map变量重命名为OurMap修复了该问题.
var Map;
Run Code Online (Sandbox Code Playgroud)
改变;
var OurMap;
Run Code Online (Sandbox Code Playgroud)