Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

get latLngBounds in Mapbox #3816

Closed
tuanht53 opened this issue Feb 4, 2016 · 2 comments
Closed

get latLngBounds in Mapbox #3816

tuanht53 opened this issue Feb 4, 2016 · 2 comments
Labels
Android Mapbox Maps SDK for Android support

Comments

@tuanht53
Copy link

tuanht53 commented Feb 4, 2016

hi, i want to get latLngBounds on Android.
What is code to get LatLngBounds for Mapbox Android?
eg: google map have code: googleMap.getProjection().getVisibleRegion().latLngBounds

@1ec5 1ec5 added the Android Mapbox Maps SDK for Android label Feb 4, 2016
@tobrun tobrun added the support label Feb 4, 2016
@tobrun tobrun added this to the android-v4.0.0 milestone Feb 4, 2016
@tobrun
Copy link
Member

tobrun commented Feb 4, 2016

@tuanht53
Thank you for reaching out and requesting this feature.
Currently we don't expose the class LatLngBouns but we will in next release (see #3754).
You will be able to use the same API as with Google Maps SDK to retrieve this (see #3758).

Workaround:

Get the LatLng value from the 4 corners:

        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));

Feed these values in CoordinateBounds, which is actually the same thing as a LatLngBounds.

I hope this solves your problem for now, reach out if you have any other questions.

@tobrun tobrun closed this as completed Feb 4, 2016
@tuanht53
Copy link
Author

tuanht53 commented Feb 4, 2016

thanks @tobrun

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android support
Projects
None yet
Development

No branches or pull requests

3 participants