Restrict map panning to an area
Replicates the MapLibre example Restrict map panning to an area: the camera cannot leave Manhattan.
The complete document
Section titled “The complete document”# yaml-language-server: $schema=https://docs.maplibre-yaml.org/schema/latest/map.schema.json# Gallery twin of https://maplibre.org/maplibre-gl-js/docs/examples/restrict-map-panning-to-an-area/# Try panning away from Manhattan — the camera snaps back inside maxBounds.type: mapid: restrict-map-panning-to-an-areaconfig: center: [-73.9978, 40.7209] zoom: 12 maxBounds: [-74.047285, 40.683927, -73.910586, 40.877645] mapStyle: "https://demotiles.maplibre.org/style.json"What to notice
Section titled “What to notice”config.maxBoundsconstrains panning and zooming-out. Its friendsminZoom/maxZoom/minPitch/maxPitchcover the other camera constraints.