-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Hello,
I have a little leaflet app as follows:
var map = L.map('map',{maxBounds:[[85.05,-180.01],[-85.06,180.05]]}).setView([0, 0], 2);
L.tileLayer('/{z}/{x}/{y}.png', {
minZoom: 1,
maxZoom: 5,
tms: true,
noWrap: true
}).addTo(map);
map.on('click', function(e){
console.log(e.latlng.toString());
});
I set the maxBounds by going to the corners of the map and clicking, which outputs the coordinates into my console (as per the code above).
When I pan left or right (west or east) past my bounds, the map immediately drags itself back to be within the bounds (as soon as I let go of the mouse). However, when I go north/south/up/down past the limits of my bounds, absolutely nothing happens. I can get to the point where there is only gray shown and no map at all, despite it all being well past the boundaries set above.
I did some testing, and noticed that if I lowered the Latitude numbers to ~80, there would be a little bit of "pulling the map back" after going past the bound, but still not enough to bring the view back into the bounds completely.
The map acts this way whether or not noWrap is set and whether or not continuousWorld is set.
Any ideas as to whether I'm doing something wrong or if maxBounds is missing some functinoality?
Sami