问题
I am using Javascript Google Maps API V3. There is a special marker in one cluster, but I want it always to be shown outside the cluster. Does anyone know how to do this?
回答1:
You can do that in the following way:
// create your marker
var marker = ....
// mark your special marker
var markerToRemove = marker;
// create marker clusterer
markerClusterer = new MarkerClusterer(map, markers, {
maxZoom: zoom,
gridSize: size,
styles: styles[style]
});
// remove your special marker from cluster
markerClusterer.removeMarker(markerToRemove);
// put it back on map
markerToRemove.setMap(map);
The last step is necessary because MarkerClusterer removeMarker()
function set map to null
so marker is not visible any more.
来源:https://stackoverflow.com/questions/21873849/how-to-separate-a-special-marker-from-a-cluster-in-google-maps