OpenLayers 2 Restricted Extent Example

map, restrict, restrictedextent, extent, light

Don't let users drag outside the map extent: instead, limit dragging such that the extent of the layer is the maximum viewable area.

Map navigation is limited by a combination of map and layer properties. The base layer resolutions array controls the resolutions (or zoom levels) available. The resolutions can be limited by setting a maxResolution property or by explicitly specifying a resolutions array.

Navigation limited by the maxExtent property. A map cannot be panned so that the center of the viewport is outside of the bounds specified in maxExtent. If you wish to further restrict panning, use the restrictedExtent property. With restrictedExtent set, the map cannot be panned beyond the given bounds. If the maxResolution allows the map to be zoomed to a resolution that displays an area bigger than the restrictedExtent, the viewport will remain centered on the restrictedExtent.