【发布时间】:2012-02-27 23:54:42
【问题描述】:
我使用 osmdroid MapView。 我需要确定用户位置是否在地图边界内(取决于缩放级别)。
我尝试使用 MapView.getBoundingBox().contain(location).. 但似乎 getBoundingBox() 返回可见边界。
有没有办法获得原始地图边界(取决于缩放级别)?
谢谢
【问题讨论】:
标签: android android-mapview osmdroid
我使用 osmdroid MapView。 我需要确定用户位置是否在地图边界内(取决于缩放级别)。
我尝试使用 MapView.getBoundingBox().contain(location).. 但似乎 getBoundingBox() 返回可见边界。
有没有办法获得原始地图边界(取决于缩放级别)?
谢谢
【问题讨论】:
标签: android android-mapview osmdroid
可以查到西北角和东南角的经纬度 您的地图视图的代码如下:
GeoPoint topLeftGpt = (GeoPoint) mapView.getProjection().fromPixels(0, 0);
GeoPoint bottomRightGpt = (GeoPoint) mapView.getProjection().fromPixels(
mapView.getWidth(), mapView.getHeight());
然后您可以确定兴趣点是否在这些范围内。
【讨论】:
对于 v2:
LatLng northwest = (LatLng) mMap.getProjection().fromScreenLocation(new Point(0, 0));
LatLng southeast = (LatLng) mGoogleMap.getProjection().fromScreenLocation(
new Point(mMapView.getWidth(), mMapView.getHeight()));
【讨论】: