Tim Nuwin
Tim Nuwin

Reputation: 2887

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.

Upvotes: 1

Views: 2434

Answers (1)

cammace
cammace

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

Related Questions