I am using Google Maps Marker Clustering Utility to cluster the markers. It unclusters on double tapping. Is it possible to do it manually on single click.
For adding a custom marker to Google Maps navigate to the app > res > drawable > Right-Click on it > New > Vector Assets and select the icon which we have to show on your Map. You can change the color according to our requirements. After creating this icon now we will move towards adding this marker to our Map.
To navigate, press the arrow keys. The number on a cluster indicates how many markers it contains. Notice that as you zoom into any of the cluster locations, the number on the cluster decreases, and you begin to see the individual markers on the map. Zooming out of the map consolidates the markers into clusters again.
Bit late to the party
In your onClusterClick function:
LatLngBounds.Builder builder = LatLngBounds.builder();
for (ClusterItem item : cluster.getItems()) {
builder.include(item.getPosition());
}
final LatLngBounds bounds = builder.build();
getMap().animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
mClusterManager
.setOnClusterClickListener(new OnClusterClickListener<MyItem>() {
@Override
public boolean onClusterClick(final Cluster<MyItem> cluster) {
map.animateCamera(CameraUpdateFactory.newLatLngZoom(
cluster.getPosition(), (float) Math.floor(map
.getCameraPosition().zoom + 1)), 300,
null);
return true;
}
});
you can do that on the click of the marker too ,
but before that you need to do map.setOnMarkerClickListener(mClusterManager);
so that cluster manager gets the click events and you can do
mClusterManagersetOnClusterItemClickListener(new OnClusterItemClickListener<MyItem>() {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With