【发布时间】:2017-09-13 19:40:57
【问题描述】:
一切正常,突然有一个错误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();
};
【问题讨论】:
-
浏览这个link。以便您了解如何创建最小、完整且可验证的示例
-
需要添加与问题相关的代码。错误是您试图从对象或其他东西中读取属性
entries,但是在您共享的代码中的任何地方都没有引用entries。我建议您阅读How to Ask 和minimal reproducible example。 -
我知道他为什么不添加代码:这个错误发生在maps.googleapis.com/maps/api/js端点;所以这似乎是谷歌地图的问题。它现在就发生在我身上。
-
问题出现在我使用的变量的名称中。变量的名称是“var Map”,所以我更改了名称,错误消失了