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'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?
The text was updated successfully, but these errors were encountered:
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:
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?
The text was updated successfully, but these errors were encountered: