You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
support fitBounds options when setting the initial map bounds #7553
Support for initial bounds as map constructor option was added in #5518, internally it uses fitBounds but it doesn't expose the fitBounds optionspadding, offset, maxZoom.
We could add a bounds_options option, but that just feels too complicated so I'm against it.
I think the best solution here will come out of #2801, which will likely open up a simpler approach to passing the initial camera state for the Map as a single object.
One possible workaround is to set the bounds without additional fitBounds options as a Map option to get it close enough at initialisation, and then immediately call map.fitBounds with the same bounds but with additional options.
This does seem to happen fast enough that no tile requests are actually made for the original bounds with no options, only tile requests for the fitBounds with options. Given this, I'd say this issue is low priority since it would really only help to reduce roadblocks for developers who face similar issues.
Activity
andrewharvey commentedon Nov 4, 2018
One possible workaround is to set the
boundswithout additionalfitBoundsoptions as aMapoption to get it close enough at initialisation, and then immediately callmap.fitBoundswith the same bounds but with additional options.This does seem to happen fast enough that no tile requests are actually made for the original bounds with no options, only tile requests for the
fitBoundswith options. Given this, I'd say this issue is low priority since it would really only help to reduce roadblocks for developers who face similar issues.pathmapper commentedon Nov 17, 2018
Such a
boundspadding option was requested in this stackoverflow comment.