How to separate a special marker from a cluster in Google maps?

风格不统一 提交于 2021-01-28 07:06:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!