Map clustering - max zoom markers still clustered

前端 未结 3 1614
花落未央
花落未央 2021-01-19 03:27

I\'m using android maps utils for clustering the markers on google maps api v2. It worked fine, but when I added 2000+ markers, on max zoom it is still clustered (markers st

3条回答
  •  爱一瞬间的悲伤
    2021-01-19 04:30

    You can extend DefaultClusterRenderer class and set minimum markers to cluster.

    public class InfoMarkerRenderer extends DefaultClusterRenderer {
    
    public InfoMarkerRenderer(Context context, GoogleMap map, ClusterManager clusterManager) {
        super(context, map, clusterManager);
        //constructor
    }
    
    @Override
    protected void onBeforeClusterItemRendered(final MyCustomMarker infomarker, MarkerOptions markerOptions) {
          // you can change marker options
    }
    
    @Override
    protected boolean shouldRenderAsCluster(Cluster cluster) {
        return cluster.getSize() > 5; // if markers <=5 then not clustering
    }
    }
    

提交回复
热议问题