简体   繁体   中英

Find the bottom left + upper right corners (latitude, longitude) with Mapbox - [Android]

Using MapBox in Android, I am trying to find the lower left corner and upper right corner. I cannot find anywhere in their documentation to retrieve this information.

This line of code should accomplish what your trying to do:

LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;

EDIT

Sorry about that, This is a feature upcoming in 4.0. for now you can use this as a work around:

int viewportWidth = mMapView.getWidth();
int viewportHeight = mMapView.getHeight();

LatLng topLeft = mMapView.fromScreenLocation(new PointF(0, 0));
LatLng topRight = mMapView.fromScreenLocation(new PointF(viewportWidth, 0));
LatLng bottomRight = mMapView.fromScreenLocation(new PointF(viewportWidth, viewportHeight));
LatLng bottomLeft = mMapView.fromScreenLocation(new PointF(0, viewportHeight));

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM