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.
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 the
maxBounds were always visible when zoomed out.
As a workaround, you might want to run something like:
map.setMinZoom( map.getBoundsZoom( map.options.maxBounds ) );
Be aware that this might change if the map container is resized.
As another workaround, I used the properties said in here!, especifically that the width or height of the world is
256*Math.pow(2, zoomLevel) pixels.
minZoom to not show beyond the bounds would be:
minZoom = Math.ceil(Math.log2(Math.max(width, height) / 256))
Which is just a development of the previous formula used with the map's width and height to find a