ClusterMarkerer - no cluster appear - this.map_.mapTypes[this.map_.getMapTypeId()] is undefined markerclusterer.js:304

白昼怎懂夜的黑 提交于 2019-12-11 02:32:11

问题


I have an issue with my MarkerClusterer.

When i was 400 markers, cluster appears, all worked. But now i have moire than 600 markers and cluster don't appear.

Firebug display this error:

that.map_.mapTypes[that.map_.getMapTypeId()] is undefined  markerclusterer.js:304

Have you an idea?

Thanks


回答1:


the best solution is switching to api 3.5 waiting a fix by google.
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.5&sensor=true"></script>




回答2:


Update your markercluster.js to the latest revision: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js

and your problem will be solved!




回答3:


It seems that google have changed something in the api. You can manually set the maxZoom value in your cluster options or in your map options to something like 16, then it works again. If you have other layers like Bing oder OSM, you have to set their maxZoom values too.

var clusterOptions = { styles: ClusterStyles, maxZoom: 16 };
markerClusterer = new MarkerClusterer(map, markersArray, clusterOptions);



回答4:


i think that maps api are changed and mapsTypes array don't has the maxZoom property




回答5:


Yep, woke up to mine broken too.

Comments here worked, I added maxZoom: 18 to my initialization.

     footer_map = new google.maps.Map(document.getElementById('footer_map'), {
      zoom: 1,
      center: new google.maps.LatLng(42, 0),
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      zoomOnClick: true,
      maxZoom: 18
    });



回答6:


In markerclusterer.js at line 156 change code from

var maxZoom = that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom;

to var maxZoom = 18;




回答7:


Same error message after "click" on cluster.

Solution:

  • use concrete version of google maps, not latest (e.g. http://maps.google.com/maps/api/js?v=3.5&sensor=true)

  • change marker clusterer js - set fixed maxZoom




回答8:


I fixed it sorta the same way but slightly different.. Best way it to update your code.. this code augments the property back where it is expected.

    var that = this;
    google.maps.event.addListener(this.map_, 'zoom_changed', function() {
        try{
           var maxZoom = that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom;
        } catch(Error){ maxZoom = that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom = 20; }
        var zoom = that.map_.getZoom();
        if (zoom < 0 || zoom > maxZoom) return;     

        if (that.prevZoom_ != zoom) {
           that.prevZoom_ = that.map_.getZoom();
           that.resetViewport();
        }
});


来源:https://stackoverflow.com/questions/7482233/clustermarkerer-no-cluster-appear-this-map-maptypesthis-map-getmaptypeid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!