googlearchive / js-marker-clusterer

A marker clustering library for the Google Maps JavaScript API v3.
https://googlemaps.github.io/js-marker-clusterer/docs/reference.html
Apache License 2.0
1.28k stars 775 forks source link

Clustering update upon filtering some markers #99

Open mbtocalli opened 7 years ago

mbtocalli commented 7 years ago

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 7 years ago

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.

gopalkohli commented 7 years ago

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

vucumbra commented 7 years ago

Cannot read property 'clearMarkers'

weijyewang commented 6 years ago

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