Reputation: 2887
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.
Upvotes: 1
Views: 2434
Reputation: 3168
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!
Upvotes: 5