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

LatLngBounds and the international dateline #9687

Closed
tobrun opened this issue Aug 2, 2017 · 1 comment · Fixed by #9747
Closed

LatLngBounds and the international dateline #9687

tobrun opened this issue Aug 2, 2017 · 1 comment · Fixed by #9747
Labels
Android Mapbox Maps SDK for Android

Comments

@tobrun
Copy link
Member

tobrun commented Aug 2, 2017

Capturing from a user.

In version 4.0.0 the latLngBounds from the projection's visible region returned with east being the point on the right hand side of the screen and west being the left. This was true even if the left was further to the west than the right side of the screen. This was a useful feature because you could tell whether the bounds should include the international date line or not.

In 4.1.1, the east and west is reversed if you are crossing the international date line. With east always being more east than the west field. This would seem correctly, but it implies that the screen is covering most of the world instead of crossing the international date line. The bounds are more useful when east represents the right side of the screen and west represents the left side of the screen. This is what I'm used to with any other latitude and longitude bounding box, so you can tell what is actually covered in the bounds.

I was able to work around this by using the farLeft and farRight fields of the VisibleRegion, but this might break other people and just isn't expected.

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Aug 2, 2017
@tobrun
Copy link
Member Author

tobrun commented Aug 10, 2017

Looked into this issue and the change mentioned in OP is related to LatLng wrapping. When getting the visible bounds the LatLng values are wrapped. When these are passed into the LatLngBounds. The bounds around the world is created instead of the minimal bounds of the visible region. To work around this a new LatLngBounds method will be added:

  LatLngBounds.from(
        topRight.getLatitude(),
        topRight.getLongitude(),
        bottomLeft.getLatitude(),
        bottomLeft.getLongitude())
    );

Currently this will be only used when getting the VisibleRegion but users that want to workaround this issue can use this method to create any bounds (input is not validated or recalculated).

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

Successfully merging a pull request may close this issue.

1 participant