Skip to content
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

Ability to set padding in options object on Map.setMaxBounds() method #11630

Open
sdl60660 opened this issue Mar 22, 2022 · 1 comment
Open

Comments

@sdl60660
Copy link

sdl60660 commented Mar 22, 2022

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:

  1. Manually finding the bounding coordinates for the larger "padded" area, which works, but is a little clunky/inexact and time-consuming.
  2. 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.

@tmcgann
Copy link

tmcgann commented Apr 26, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants