【发布时间】:2013-02-05 05:01:26
【问题描述】:
我在我的应用程序中使用 Google Maps v2。当用户在屏幕上平移或缩放时,我想获取地图的区域,我希望仅在屏幕视图部分中获取 POI。
我浏览了文档,但找不到任何帮助。
【问题讨论】:
标签: android google-maps-android-api-2 bounds
我在我的应用程序中使用 Google Maps v2。当用户在屏幕上平移或缩放时,我想获取地图的区域,我希望仅在屏幕视图部分中获取 POI。
我浏览了文档,但找不到任何帮助。
【问题讨论】:
标签: android google-maps-android-api-2 bounds
您需要使用 Projection 和 VisibleRegion 类才能获得可见的 LatLng 区域。
所以你的代码看起来像:
LatLngBounds curScreen = googleMap.getProjection()
.getVisibleRegion().latLngBounds;
【讨论】:
LatLngBounds.contains(LatLng point) 接口。但是,在地图上显示大量标记是另一回事
[curScreen.southwest.longitude;curScreen.northeast.latitude],右下角的坐标是[curScreen.northeast.longitude;curScreen.southwest.latitude]。您可以将纬度视为Y 轴,将经度视为X 轴
在 Android(Kotlin) 中,您可以通过这种方式找到 LatLng,每次缩放或。手势检测
private var mMap: GoogleMap? = null
..........
mMap?.setOnCameraMoveStartedListener { reasonCode ->
if (reasonCode == GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE) {
val curScreen: LatLngBounds = mMap!!.getProjection().getVisibleRegion().latLngBounds
var northeast=curScreen.northeast
var southwest=curScreen.southwest
var center=curScreen.center
Log.v("northeast LatLng","-:"+northeast)
Log.v("southwest LatLng","-:"+southwest)
Log.v("center LatLng","-:"+center)
}
}
【讨论】: