Clustering map markers on zoom out and unclustering on zoom in

前端 未结 4 1324
南旧
南旧 2020-12-30 17:19

I am using the Google Map Android clustering Utitlity With Google Maps v2 play services.

I am not getting the behavior I expected. As you can see in the two images

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-30 18:11

    You can change your minimum cluster size. By Default minimum cluster size is 4 defined in map-utils library as below.

        /**
         * If cluster size is less than this size, display individual markers.
         */
        private int mMinClusterSize = 4;
    
        /**
         * Determine whether the cluster should be rendered as individual markers or a cluster.
         */
        protected boolean shouldRenderAsCluster(Cluster cluster) {
            return cluster.getSize() > mMinClusterSize;
        }
    

    Or you can override shouldRenderAsCluster method in your extended DefaultClusterRenderer class as below:

    @Override
    protected boolean shouldRenderAsCluster(Cluster cluster) {
        // Always render clusters.
        return cluster.getSize() > 1;
    }
    

提交回复
热议问题