googlearchive/js-marker-clusterer

Clustering update upon filtering some markers

mbtocalli opened this issue · 4 comments

I have a Google Map with several markers. When I filter markers by categories using a simple select, the correct markers are set to visible and the others are not showing. However, the clustering is not updating. I think is becasue recognize the hidden markers. Is it possible to solve this issue?

ifunk commented

You can use cluster.clearMarkers() and cluster.addMarkers(yourFilteredMarkers) to re-cluster filtered markers, but you'll need to provide the array of markers of course. It's what I'm doing in my project and works well.

@ifunk I tried your hack, but still on filtering clusters are there.

Cannot read property 'clearMarkers'

@vucumbra the clearMarkers function is attached to MarkerClusterer class

this.markerCluster = new MarkerClusterer(this.googleMap, this.markers,
      { imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m' }
    );

this.markerCluster.clearMarkers();