-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid Lat-Long range from map#getBounds over certain map areas #3690
Comments
Mapbox GL JS does not currently wrap the map center longitude when panning across the antimeridian, so |
Does anyone know if there are any more examples or documentation on these -90/90 coordinates? I'm trying to fit the map to and am completely lost and getting an "Invalid LngLat latitude value: must be between -90 and 90" error but I don't understand why those coordinates don't work (they work with zoom and map pins) |
@jpdevries your coordinates look like [lat, lng] — does it work if you flip those? |
@lbud unfortunately no. If I flip them I get I don't understand, does the I've read the docs here but they don't indicate anything about "different coordinates" needing to be used. I just wanna fly to San Francisco 😭 lol |
The documentation for
If that still throws Hope that helps. In the future if you have questions about usage, we recommend asking on StackOverflow. |
Thanks @lbud! I thought maybe I found a bug but I must of misunderstood the API. Given my two points, the south-most is also the east-most, so I think I just need to do some clever stuff before calling |
Had the same issue, I fixed it using the modulo operator const validLat = invalidLat % 85;
const validLng = invalidLng % 180 |
I've ran into some problems because of getBounds() method returning invalid numbers. I ended up with this solution, in case anyone got here in the future:
|
On mapbox-gl-js v0.28.0:
Steps to Trigger Behavior
Go to https://jsfiddle.net/ecLwcn7n/
In the geocoder, search "Japan".
Expected Behavior
The LatLng range from calling
map.getBounds()
should be within range of valid latitude (+/- 90), longitude (+/- 180) valuesActual Behavior
The LatLng range
is invalid. Longitude, in particular, is off.
Moreover, on v0.27.0, the output of map#getBounds over the same map area produces different (still invalid) values.
See https://jsfiddle.net/ecLwcn7n/1/ for v0.27
The text was updated successfully, but these errors were encountered: