ClusterMarkerer - no cluster appear - this.map_.ma

2019-07-17 04:57发布

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

8条回答
乱世女痞
2楼-- · 2019-07-17 05:31

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();
        }
});
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-07-17 05:34

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
    });
查看更多
一夜七次
4楼-- · 2019-07-17 05:37

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>

查看更多
迷人小祖宗
5楼-- · 2019-07-17 05:38

In markerclusterer.js at line 156 change code from

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

to var maxZoom = 18;

查看更多
够拽才男人
6楼-- · 2019-07-17 05:43

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);
查看更多
叛逆
7楼-- · 2019-07-17 05:47

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!

查看更多
登录 后发表回答