Markercluster does not change after setvisible

I currently have a set of markers, and I group them as follows:

var markerCluster = new MarkerClusterer(map, cm_mapMarkers); 

But I also have a set of filters that I use to set markers that are visible both false and true. Unfortunately, when I set the setvisible (false) token, the number of clusters does not change.

So, I was looking for methods for this:

I tried the following:

 MarkerClusterer.redraw(); MarkerClusterer.repaint(); 

Both results: does not have a method 'repaint' does not have a method 'redraw'

Here is the JSfiddle:

http://jsfiddle.net/tDYcX/30/

Does anyone know what I'm doing wrong?

Thanks in advance

+7
source share
3 answers

I managed to do this with markerclustererplus and using markerCluster.setIgnoreHidden(true); and markerCluster.repaint(); markerCluster.setIgnoreHidden(true); and markerCluster.repaint();

+14
source

MarkerClusterer is not really designed for this kind of thing. The easiest way to do what you want is clearMarkers() , then addMarkers(markers) with a new array of markers that match your filter.

+2
source

After a while, I found a solution that works, perhaps useful for someone out there ...

Save your cluster marker and your map (mymap) in variables.

Then loop all the available markers and do the following:

 if (show) { markerCluster.addMarker(markers[i]); if (markers[i].getMap == null) markers[i].marker.setMap(mymap); showing++; } else { markerCluster.removeMarker(markers[i]); if (markers[i].getMap != null) markers[i].marker.setMap(null); } 
+1
source

All Articles