Integrating Spiderfier JS into markerClusterer V3 to explode multi-markers with exact same long / lat

后端 未结 5 976
我在风中等你
我在风中等你 2020-12-23 14:27

I am using markerCLusterer V3 on a db file from Filemaker to generate a (semi-live) map of current delivery locations, based off of addresses. Grabbing the lat/long from Go

5条回答
  •  Happy的楠姐
    2020-12-23 15:31

    Setting the max zoom will fix the problem:

    minClusterZoom = 14;
    markerCluster.setMaxZoom(minClusterZoom);
    

    but for viewing purposes you may want to create a clusterclick listener to prevent it from zooming in really close on a cluster of points at the same location (clicking a cluster set the bounds of the map to cover the points in the cluster; if all points are at the same location it will zoom in all the way, which tends to look bad):

    google.maps.event.addListener(markerCluster, 'clusterclick', function(cluster) {
        map.fitBounds(cluster.getBounds()); // Fit the bounds of the cluster clicked on
        if( map.getZoom() > minClusterZoom+1 ) // If zoomed in past 15 (first level without clustering), zoom out to 15
            map.setZoom(minClusterZoom+1);
    });
    

提交回复
热议问题