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

[android] Wrapping LatLngBounds for shortest path results in ambiguous bounding box behavior #13186

Closed
ryanhamley opened this issue Oct 24, 2018 · 1 comment
Labels
Android Mapbox Maps SDK for Android archived Archived because of inactivity bug

Comments

@ryanhamley
Copy link
Contributor

Platform: Android (possibly Core)
Mapbox SDK version: All

Steps to trigger behavior

setLatLngBoundsForCameraTarget expects a LatLngBounds with coordinates in the [ne, sw] order. The expectation is that the eastern longitude value will be less than the western longitude value. This assumption, combined with wrapping all coordinates to be between 180 and -180 by calling unwrapForShortestPath, introduces ambiguity in how bounding boxes can be created. Consider this example:

map.setLatLngBoundsForCameraTarget(LatLngBounds.from(20, 170.0 /*east*/, -20.0, -170.0 /*west*/));

One would expect a bounding box that covers most of the Earth's surface centered on the prime meridian with its east longitude at 170 and the west value at -170 but setLatLngBoundsForCameraTarget eventually results in a call to unwrapForShortestPath which converts these coordinates to 170 for the west longitude and 190 for the east longitude, resulting in a small bounding box spanning the antimeridian. See discussion starting here.

  1. Add map.setLatLngBoundsForCameraTarget(LatLngBounds.from(20, 170.0 /*east*/, -20.0, -170.0 /*west*/)); to your map
  2. View map and attempt to pan around

Expected behavior

Map should be centered on prime meridian and able to pan along the equator for most of the world's width

Actual behavior

Panning is fixed to a small box around the antimeridian.

Related tickets:
#13006
#13087

cc @ansis @LukasPaczos

@stale
Copy link

stale bot commented Apr 23, 2019

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Apr 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android archived Archived because of inactivity bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant