L.latLngBounds swapping longitude of Northeast and Southwest point
See original GitHub issueConsider the example below
var southWest = L.latLng(-7.12725588946924, 159.14), northEast = L.latLng(70.0415297179124, 24.855900000000005);
var bounds = L.latLngBounds(southWest, northEast);
//logs - LatLng(-7.12726, 159.14), LatLng(70.04153, 24.8559)
console.log(southWest.toString(), northEast.toString());
//logs - LatLng(-7.12726, 24.8559)
console.log('bounds SW: ', bounds.getSouthWest().toString());
//logs - LatLng(70.04153, 159.14)
console.log('bounds NE: ', bounds.getNorthEast().toString());
Longitude for SouthWest and NorthEast points are swapped in the bounds. Why? This seems like a very bad bug. Issue reproduction - http://jsbin.com/huziqi/edit?html,console
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
L.latLngBounds swapping longitude of Northeast and ... - GitHub
Longitude for SouthWest and NorthEast points are swapped in the bounds. Why? This seems like a very bad bug. Issue reproduction - http://jsbin....
Read more >leaflet - L.latLngBounds swapping longitude of Northeast and ...
i am trying to adjust map in a certain way. logs of general bound: bottomRight: (2) [11.525595058977732, 140.82915421731286] topLeft: (2) ...
Read more >LatLngBounds | Google Play services
Creates a new bounds based on a southwest and a northeast corner. The bounds conceptually includes all points where: the latitude is in...
Read more >L.LatLngBounds - WRLD3D
LatLngBounds. Represents a rectangular geographical area on a map. Usage example. var southWest = L.latLng(40.712, -74.227), northEast = L.latLng(40.774, ...
Read more >One Way to Give a National Map Geographical Detail
You'll note Alaska is an exception to this method, as it's true geographical bounds extend past the anti-meridian or 180th meridian, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
If I am not mistaken, the conventional cardinal directions and latitude / longitude ranges are:
Therefore your
southWest = L.latLng(-7.12725588946924, 159.14)
would actually be more East than yournorthEast = L.latLng(70.0415297179124, 24.855900000000005)
.When creating your
bounds
out of these corners, Leaflet detects the correct positions for you. Is not it great? 😃@aaani Look at your blue polygon, it crosses the dateline.
A very easy workaround would have been to use a longitude of 159.14 - 360 = -200.86 to reach the left copy of the world. Demo: https://jsfiddle.net/3v7hd2vx/80/
See https://github.com/Leaflet/Leaflet/pull/1293