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

Maxbounds pixel buffer setting? #5997

Closed
stevage opened this issue Jan 14, 2018 · 2 comments
Closed

Maxbounds pixel buffer setting? #5997

stevage opened this issue Jan 14, 2018 · 2 comments

Comments

@stevage
Copy link
Contributor

stevage commented Jan 14, 2018

This a suggestion for a tweak to the maxBounds setting. (It may be too niche, so feel free to reject it :))

Currently a map's maxBounds specifies that the four corners of the map will never be outside the lat/long boundaries of the maxBounds. I am finding that sometimes this isn't ideal, when you have controls or overlays sitting inside the map area.

A concrete example:

  • I have the western boundary of maxBounds set to 140, which is the western boundary of the state of Victoria. (This particular map is for a state-based agency). Minzoom is 6 (which shows the whole state).
  • There is a legend sitting just inside the left margin of the map, 315px wide out of 890px. (It's not very tall, so doesn't obscure much space).
  • Problem: when the user zooms out fully, part of the state is obscured by the legend.
  • Solution 1: move the western boundary of maxBounds a lot further west, which isn't ideal, as it creates a huge amount of area where the user could get lost, at higher zooms.
  • Solution 2: decrease minZoom, which creates more issues for data preparation and cartography, and also doesn't totally solve the problem of the user wanting to see lots of the state at a higher zoom level.

Proposed solution: allow some kind of maxBoundsBuffer setting which changes the definition of maxBounds. Instead of the four corners being constrained to the maxBounds, a rectangle inset by maxBoundsBuffer will be constrained. So in my case, the user could pan 315px further left than currently, so the legend doesn't obscure the map.

@mourner
Copy link
Member

mourner commented Jan 15, 2018

Yes, we should definitely add this. Closing this as a duplicate of #4268

@mourner mourner closed this as completed Jan 15, 2018
@tmcgann
Copy link

tmcgann commented Apr 26, 2022

#4268 was apparently addressed by #8638. However, it doesn't seem to help for maxBounds but instead helps with fitBounds | flyTo | easeTo type functions. Is the fix to use Map.padding or Map.setPadding in combination with maxBounds? This feels really disjointed.

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

No branches or pull requests

3 participants