I wrote the following method to display my markers (clustered). However, some of the clusters work fine - i.e. when I zoom in, the blue cluster icon (that says 10+ for ex) goes away and reveals the individual markers. However, some times, when I zoom in fully, the blue cluster marker is still displayed on full zoom ALONG with one of the individual markers. Why is this happening?
private void displayCluster(List<MyItem> items) {
mClusterManager = new ClusterManager<MyItem>(this, googleMap);
mClusterManager.setRenderer(new MyRender(getApplicationContext(),googleMap,mClusterManager));
googleMap.setOnCameraChangeListener(mClusterManager);
googleMap.setOnMarkerClickListener(mClusterManager);
for (MyItem item : items) {
mClusterManager.addItem(item);
}
}
DefaultClusterRenderer decides whether the markers should be clustered or not.This class contains DefaultClusterRenderer#shouldRenderAsCluster() method - in which the clustering starts only when size of cluster is > MIN_CLUSTER_SIZE. Default value of MIN_CLUSTER_SIZE is 4.
You need to extend DefaultClusterRenderer class and override shouldRenderAsCluster() method to provide your own logic: