[英]How to zoom enough to unfold a cluster with Android Maps Extensions?
Sometimes when markers are really close to each other, it requires many clicks to zoom enough so that the cluster unfolds and shows all the markers individually. 有时,当标记确实彼此接近时,需要多次单击才能充分缩放,以使群集展开并单独显示所有标记。
How can I make it so that one click on a cluster always zooms in and unfolds it correctly? 如何使群集上的一键始终放大并正确展开?
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 (eg in
onMarkerClick
): 如果可以的话,请按以下步骤操作(例如,在
onMarkerClick
):
Marker.isCluster
Marker.isCluster
Marker.getMarkers
Marker.getMarkers
GoogleMap.getMinZoomLevelNotClustered
and remember the largest value from the loop GoogleMap.getMinZoomLevelNotClustered
并记住循环中的最大值 GoogleMap.animateCamera
with some LatLng
and the largest zoom value LatLng
和最大的缩放值调用GoogleMap.animateCamera
The problem here is to decide what LatLng
to choose. 这里的问题是决定选择哪种
LatLng
。 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. 或者,您可能需要缩放到从集群中所有标记创建的
LatLngBounds
。 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. 这不会显示所有标记,但是可以肯定的是,最终所有标记仍将隐藏在屏幕上的某个位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.