问题
I have implemented cluster
in google map and I want to update the map with the markers
based on the checkbox selection.
I want to remove the marker from the cluster based on the custom property that I have set in the marker.
var clust = new MarkerClusterer(map, markers, {maxZoom: 14});
How can I do this? Please help me.
Thanks in advance.
回答1:
For each marker to remove:
clust.removeMarker(marker);
For each Marker to add:
clust.addMarker(marker);
回答2:
You need to set map null for current markercluster and then create new marker array on the basis of property you want then create new markercluster again and set to map.
var clust = new MarkerClusterer(map, markers, {maxZoom: 14});
on update property
clust.setMap(null)
var newclust = new MarkerClusterer(map, newmarkers, {maxZoom: 14});
newclust.setMap(mapobject)
来源:https://stackoverflow.com/questions/25302466/how-to-remove-the-marker-from-the-cluster-in-google-map