最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Cannot read property 'entries' of undefined in http:maps.googleapis.commapsapi - Stack Overflow

programmeradmin2浏览0评论

Everything worked and suddenly there was a mistake Cannot read property 'entries' of undefined that it could be ? (including 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();
};

Everything worked and suddenly there was a mistake Cannot read property 'entries' of undefined that it could be ? (including 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();
};
Share edited Sep 14, 2017 at 21:01 Dmitry Pavlov 28.4k7 gold badges100 silver badges128 bronze badges asked Sep 13, 2017 at 19:40 Арсен ГзирянАрсен Гзирян 611 silver badge4 bronze badges 5
  • 1 Go through this link. So that you can understand How to create a Minimal, Complete, and Verifiable example – Jino Shaji Commented Sep 13, 2017 at 19:49
  • You need to add the code related to the problem. The error is that you are trying to read the property entries from an object or something, but in the there's no reference to entries anywhere in the code that you shared. I'd remend you to read How to Ask and minimal reproducible example. – Alvaro Montoro Commented Sep 14, 2017 at 16:24
  • I know why he didn't add the code: this error is happening in the maps.googleapis./maps/api/js endpoint; so it seems to be a Google Maps issue. It's happening to me right now. – Phillip Gruneich Commented Sep 14, 2017 at 20:52
  • 1 Possible duplicate of Google Maps API Error with no changes in the page code – Phillip Gruneich Commented Sep 14, 2017 at 20:58
  • 2 Problen was in the name of the variable I used. The name of variable was "var Map", so i changed the name and error has gone – Арсен Гзирян Commented Sep 15, 2017 at 16:52
Add a ment  | 

2 Answers 2

Reset to default 9

Google changed their Maps API script November 2017. They started using global variable Map which broke our site. Renaming the Map variable to OurMap in our script fixed the issue.

var Map;

changes to;

var OurMap;

it was solved by adding version param

https://maps.googleapis./maps/api/js?v=3&key=&callback=Map.init

发布评论

评论列表(0)

  1. 暂无评论