Map clustering - max zoom markers still clustered

前端 未结 3 1612
花落未央
花落未央 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:19

    Via trail and error I found that if the markers are within ~10 feet (equivalent to 0.0000350º difference in lat or long), the markers don't decluster even at the max zoom level.

    One way to solve for this problem is to implement a custom Renderer and let the app decide when to cluster. For example, the below code will cluster only when there are more than 1 marker and not at max Zoom. In other words it will decluster all markers at max zoom.

    mClusterManager.setRenderer(new DefaultClusterRenderer(mContext, googleMap, mClusterManager) {
        @Override
        protected boolean shouldRenderAsCluster(Cluster cluster) {
            if(cluster.getSize() > 1 && mCurrentZoom < mMaxZoom) {
                return true;
            } else {
                return false;
            }
        }
    });
    

提交回复
热议问题