Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top