-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Add zoomOffset option to fitBounds #6100
base: main
Are you sure you want to change the base?
Conversation
Hi, Thank you for submitting your first PR here! If I understand correctly, you would like your map to I can understand that you would like an extra option in Leaflet core to fit your use case, but it seems to me that you could already achieve something similar with the current API, using // Compute the appropriate zoom level, without having the map actually change its view.
var fitZoom = map.getBoundsZoom(bounds);
map.setView(bounds.getCenter(), fitZoom - 1); Example: https://plnkr.co/edit/W3dJjQBeP2RFLRTQLlRJ?p=preview |
Exactly, although it could be anything and not just 1 zoom level lower. Thanks for pointing how to achieve the same result with the current API - but my point with this PR was more to suggest adding this option, just like there's the But feel free to close it if you don't think that's a common enough use case. |
Hi, Sorry for not getting back to you earlier. |
Hi @ghybs, I just added 2 tests:
Btw there's no option |
I'm not sure that it is really common case.
For me such option would look a bit weird. May be better address such issue in more direct way (I mean fix |
Add an option to offset the zoom level after
fitBounds
- I feel like it's common use case to want to fit the bounds and then zoom out.I've had some trouble calling
map.zoomOut()
right afterfitBounds
, even when disabling the animation (eg, tiles not loaded, marker positions are wrong...) and thought it would just be better to add this as an option tofitBounds
.Let me know what you think