我在我的安卓应用程序中有一个MapFragment,现在我想知道地图上实际显示的最小和最大拉/长。
我找到了这个解决方案:
如果您想找出MapView角的经度纬度,可以使用:
Point mapCenter = mapView.getMapCenter();
int latitudeSpan = mapView.getLatitudeSpan() / 2;
int longitudeSpan = mapView.getLongitudeSpan() / 2;
int topLeftLat = mapCenter.getLatitudeE6() + (latitudeSpan);
int topLeftLon = mapCenter.getLongitudeE6() - (longitudeSpan);
int bottomLeftLat = mapCenter.getLatitudeE6() - (latitudeSpan);
int bottomLeftLon = mapCenter.getLongitudeE6() + (longitudeSpan);我现在的问题是我没有MapView,我只有GoogleMap (com.google.android.gms.maps.GoogleMap)和MapFragment (com.google.android.gms.maps.MapFragment)。
我需要min/max坐标来执行一个DB查询,以选择POI入口。
发布于 2013-01-31 21:26:58
您可以使用来自GoogleMap的getVisibleRegion从Projection获得它。
假设您将GoogleMap命名为map,则需要
VisibleRegion bounds = map.getProjection().getVisibleRegion();VisibleRegion不一定是一个矩形,但给您的边界,请参阅文档获得更多信息。
发布于 2013-02-01 17:55:37
要添加到伊格伦的答案,您可能对可见区域调用上的LatLngBounds感兴趣。
LatLngBounds bounds = this.mMap.getProjection().getVisibleRegion().latLngBounds;由此,你可以得到最小/最大纬度/经度(东北/西南角)。
不确定你想用它做什么,但是如果你想检查一个标记是否“在屏幕上”,那么你可能对这个答案感兴趣。
https://stackoverflow.com/questions/14634735
复制相似问题