无法在http://maps.googleapis.com/maps/api/中读取未定义的属性“条目”

问题描述 投票:-5回答:2

一切都工作,突然有一个错误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();
};
javascript google-maps
2个回答
9
投票

Google于2017年11月更改了他们的Maps API脚本。他们开始使用全局变量Map来破坏我们的网站。在我们的脚本中将Map变量重命名为OurMap修复了该问题。

var Map;

改变;

var OurMap;

3
投票

它是通过添加版本参数来解决的

https://maps.googleapis.com/maps/api/js?V = 3&关键=&回调= Map.init

© www.soinside.com 2019 - 2024. All rights reserved.