我的Android应用程序中有一个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)。
我需要最小/最大坐标来进行数据库查询以选择POI-DB-Entrys。
答案 0 :(得分:2)
您可以使用GoogleMap
Projection
从GoogleMap
获取此邮件。
假设您将map
命名为VisibleRegion bounds = map.getProjection().getVisibleRegion();
,则执行
VisibleRegion
{{1}}不一定是矩形,但为您提供界限,请参阅getVisibleRegion
以获取更多信息。
答案 1 :(得分:0)
要添加到iagreen的答案,您可能对可见区域调用中的LatLngBounds感兴趣。
LatLngBounds bounds = this.mMap.getProjection().getVisibleRegion().latLngBounds;
由此,您可以获得最小/最大纬度/经度(东北/西南角)。
不确定您要对此做些什么,但如果您想检查标记是否在“屏幕上”,那么您可能会对this answer感兴趣