Pregunta

Currently I have a set of markers and I cluster them like this:

var markerCluster = new MarkerClusterer(map, cm_mapMarkers);

But I also have a set of filters which i use to set markers visible false or true. Unfortunatly when I set the marker setvisible(false) the cluster count is not changing.

So I looked for methods to do this:

I tried the following:

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

Both resulting in : has no method 'repaint' has no method 'redraw'

Here is a JSfiddle:

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

Anybody knows what I am doing wrong?

Thanks in advance

¿Fue útil?

Solución

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

Otros consejos

The MarkerClusterer isn't really designed for that sort of thing. The easiest way to do what you want is to clearMarkers() then addMarkers(markers) with a new array of markers that match your filter.

After a while of trying, I found a solution that works, maybe helpful for someone out there ...

Save your markerCluster and your map (mymap) in variables.

Then loop throuth all of your available markers and to like this:

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);
    }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top