In Leaflet 1.0.2, if you set maxBounds
on a map, it prevents panning beyond those bounds, but does not prevent zoom out beyond them. Is this by design? It seems incorrect behaviour to me. I need to prevent display of the map beyond given bounds, and thought maxBounds
would do it.
[GIS] Leaflet maxBounds doesn’t prevent zooming out
extentsleaflet
Best Answer
This is by design, or rather said, by default. The devs (me included) thought "well, users already have
minZoom
to prevent this kind of thing", so the focus was on making sure that themaxBounds
were always visible when zoomed out.As a workaround, you might want to run something like:
Be aware that this might change if the map container is resized.