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 prevents the map's center from reaching the max bounds in some cases. #13223

Open
Jdyn opened this issue Jul 14, 2024 · 0 comments
Open

Comments

@Jdyn
Copy link

Jdyn commented Jul 14, 2024

mapbox-gl-js version:
3.5.1
browser:
Chrome

Steps to Trigger Behavior

  1. Set max bounds to max lat 90
 maxBounds: [
   [-360, -90],
   [360, 90]
 ],

Note how the Map center is able to reach the bounds, and the map displays "empty" area which is desired.

  1. Set max bounds to arbitrary bounds
  maxBounds: [
    [-360, -62],
    [360, 75]
  ]

The map center is unable to reach the max bounds like before, and no empty area is able to be displayed.

Link to Demonstration

Untitled.mov

Notes

I understand if this behavior is considered somewhat intentional, but I think there needs to be an option that essentially allows adding empty space, and panning beyond the max bounds until a specific camera edge is reached.

for example we could have:

maxBoundsEdges: 'within' | 'centered' | 'contained'

contained: all edges of the camera must be within the max bounds (current behavior except at 90 lat)
centered: the camera center must be within the maxbounds, but edges can go beyond
within: the camera must contain one edge within the maxBounds, but it can pan beyond in all directions.
        EX: the left side of the camera can pan up to the right side of the maxBounds and so on.

In all cases, empty space can be displayed when panning outside the bounds.

Note I could not get the global map.setPadding to have any effect on this

Expected Behavior

I expect that when the camera attempts to pan to the maxBounds, the map center is able to reach the max bounds, consistent with when the maxBounds are -90, 90.

The behavior of maxBounds with -90, 90 is a much better user experience.

Actual Behavior

When using a lat that is not -90, 90, the map center is unable to pan to the bound's edges, and no empty space is added beyond the map.

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

2 participants