Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
fitBounds with padding zooms the map really far out #4528
I am not sure if this is a regression or not, but I have experienced that since the RC1 release the map
The padding is just really big and the map is zoomed far out. We have used this function with the padding on layer containing SVG polygon also and since RC1 that also started to act strange by zooming the map really far out.
I can get the same result on RC1 by setting the
The culprit seems to be this line:
boundsSize = this.project(se, zoom).subtract(this.project(nw, zoom)).add(padding),
That's getting the size (in pixels) of the bounds to fit, at the current zoom level, then adding the padding.
What we really want is to have the padding at the destination zoom level, not at the original zoom level.
A possible solution would be to subtract
I think this is a rather self-contained, explained bug, so I think any newbie can try fixing this. (Hello, @yourfirstpr!).
Things to be done:
I'd just like to add to the list:
For development of fitBounds I believe the best is to use zoomSnap: 0, as snapping to an integer zoom level will usually add a big padding on it's own.
Thank you for your interest in Leaflet!
This thread is already closed, since the bug it describes has already been fixed in PR #4532.
Keep up the good work and feel free to ask!