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

StackOverflow https://stackoverflow.com/questions/7482233

Question

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

Was it helpful?

Solution

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>

OTHER TIPS

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!

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);

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

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
    });

In markerclusterer.js at line 156 change code from

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

to var maxZoom = 18;

Same error message after "click" on cluster.

Solution:

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();
        }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top