我使用osmdroid MapView。 我需要找到用戶在地圖邊界內的位置(取決於縮放級別)。需要檢查一個特定的位置是否在地圖的邊界內
我嘗試用戶MapView.getBoundingBox()。contains(location)..但似乎getBoundingBox()返回可見邊界。
有沒有辦法獲得原始地圖邊界(取決於縮放級別)?
感謝
我使用osmdroid MapView。 我需要找到用戶在地圖邊界內的位置(取決於縮放級別)。需要檢查一個特定的位置是否在地圖的邊界內
我嘗試用戶MapView.getBoundingBox()。contains(location)..但似乎getBoundingBox()返回可見邊界。
有沒有辦法獲得原始地圖邊界(取決於縮放級別)?
感謝
你可以找出緯度和西北的經度和東南角您的MapView的 有類似的代碼:
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()));