[Android] Get visible bounds
Guys,
Is is possible to get visible bounds? I haven't find any suitable method. I know how to set it (setVisibleCoordinateBounds) but getter would be also very useful. Maybe a workaround is to compute it using center point and zoom, but it doesn't look nice...
Thanks in advance!
@mpuchala, thank you for reaching out
getVisibleBounds is currently not a getter we support but you can use this workaround:
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));
You can then feed these values in a VisibleCoordinateBounds in the 3.2.0 release. For the 4.0.0 we are thinking about exposing this as Google Maps SDK is exposing in #3758.
Reach out if you have any other questions.
Awesome! Much Thanks!
Cannot find the new way of getting the visible bounds, has it been released yet or should we continue using the example above.
Projection#getVisibleRegion
val bounds: LatLngBounds = mapboxMap.projection.visibleRegion.latLngBounds