If you wanted to zoom to show all the markers from a single cluster, you could end up showing only some of them. If that's ok with you, here are the steps (e.g. in onMarkerClick
):
- check if
Marker.isCluster
- loop over
Marker.getMarkers
- for every marker call
GoogleMap.getMinZoomLevelNotClustered
and remember the largest value from the loop
- after loop call
GoogleMap.animateCamera
with some LatLng
and the largest zoom value
The problem here is to decide what LatLng
to choose. If you choose the one from cluster marker, you could even end up not showing any marker after zoom.
Alternatively you may want to zoom to LatLngBounds
created from all the markers in the cluster. This will not make it to show all markers, but for sure you would end up with all markers still hidden somewhere on the screen.