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
I have no idea what this looks like under the hood, so I don't know if this would be a quick change or more complicated, but it would be great to be able to pass an options object with padding to the setMaxBounds method, like I'm able to do with fitBounds.
Motivation
I've had a few times where I want to restrict panning on a map to a particular region, but want to be able to set some padding around the edges. Workarounds that I've tinkered with, but aren't ideal are:
Manually finding the bounding coordinates for the larger "padded" area, which works, but is a little clunky/inexact and time-consuming.
Running fitBounds with padding set, grabbing the new bounds with getBounds, feeding this into maxBounds and then restoring the original map position without transition.
It would be great if there was a way to set this easily, if that's easy to do.
The text was updated successfully, but these errors were encountered:
There's some older issues that try to address this same need. I've added a comment and referenced other issues here: #6969 (comment).
Agree that something like this could be helpful. I personally would prefer an option that makes the behavior similar to fitBounds since I wouldn't want to calculate the desirable padding since it could vary in my use case (i.e. I don't need padding for a static legend or similar; I want to see an entire country in the viewport). However, if there were an easy way to calculate the padding and that fulfilled my requirements I'd be open to it. Our use cases may merit different functionality ultimately.
I have no idea what this looks like under the hood, so I don't know if this would be a quick change or more complicated, but it would be great to be able to pass an options object with
padding
to thesetMaxBounds
method, like I'm able to do withfitBounds
.Motivation
I've had a few times where I want to restrict panning on a map to a particular region, but want to be able to set some padding around the edges. Workarounds that I've tinkered with, but aren't ideal are:
fitBounds
with padding set, grabbing the new bounds withgetBounds
, feeding this intomaxBounds
and then restoring the original map position without transition.It would be great if there was a way to set this easily, if that's easy to do.
The text was updated successfully, but these errors were encountered: