I am currently using markercluster plugin with jquery ui maps.
I have two arrays one of all markers (called markers) and one of markers that match search criteria (called current_markers). These are fitered from the first array.
I then draw the current_markers on screen.
I am finding however that the markerclusterer library is not updating based on this change.
So how can I update the markerclusterer?
Is it possible to assign the markerclusterer to a variable and call an update function?
You should store the marker object in a var and then unset the map as following:
after you've done this, you could init a
new MarkerClusterer
with new markersUpdate
since you are using google maps ui plugin here's some additional code. I've added a click even on a button with class
reset_markercluster
ofcourse this is just to show how to use it to call the mapYes you can.
Creating the map
Assuming you have created your MarkerClusterer object something like this:
Adding markers
You can add multiple markers to it something like this:
Note that here I have added only one.
Removing all markers
You can then clear all the markers using clearMarkers something like this:
Note that for tidiness I have also unset the markers array here.
Docs
Full documentation on all the available methods is available here:
https://googlemaps.github.io/js-marker-clusterer/docs/reference.html
It's a sensible and relatively complete API.
marker-clusterer-plus has a
removeMarkers
method:It's best to use the clearMarkers() method from your markerCluster object:
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/docs/reference.html