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

No way to set maxBounds for only one dimension #3081

Closed
erahhal opened this issue Dec 7, 2014 · 3 comments
Closed

No way to set maxBounds for only one dimension #3081

erahhal opened this issue Dec 7, 2014 · 3 comments

Comments

@erahhal
Copy link

erahhal commented Dec 7, 2014

I'm creating a run of the mill web mercator world map, and would like to prevent panning beyond the poles in the vertical direction, but allow infinite wrap around in the horizontal direction. The only way I've found to do this is adding the following maxBounds option to the map object:

var southWestBound = L.latLng(-85, -99999);
var northEastBound = L.latLng(85, 99999);
var maxBounds =  L.latLngBounds(southWestBound, northEastBound);

This works, but with a few issues. First, it's not correct - if you keep moving in one direction horizontally you will still hit a bound. Also, without knowing the architecture of Leaflet, it's unclear if it will cause caching issues. Unclear whether markers will wrap around as well (haven't tried it yet). Lastly, if you use this hack, the tiles keep flickering in each time you wrap around the world boundary, as Leaflet thinks they are new tiles.

What is the correct way of doing this?

@IvanSanchez
Copy link
Member

Did you try to use Infinity / -Infinity?

@mourner
Copy link
Member

mourner commented May 12, 2015

I would be surprised if it works — probably not...

@IvanSanchez
Copy link
Member

Then prepare to be surprised by #3465.

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