-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Description
I'm experiencing issues with setting the map viewport with fitBounds when bounds is a large rectangle. I've looked into the code and it seems the fitBounds uses setView with L.latLngBounds(bounds).getCenter() as center. But this is not correct if the map uses a Mercator projection. If i want to set the map to a latitude range of (0, 85) your calculation uses 42.5 as center latitude. But in a mercator world the correct latitude is 66.5!
The correct calcuation would be:
- project the LatLng bounds on the map projection bounds
- calculate the center on the projected bounds
- re-project the center on LatLng
- use this point for setView
Don't know if this also affects other methods on the map.