Files
openlayers/examples/restricted-extent.html
crschmidt efb925d632 Commit fixes for:
* (Closes #2360) make Layer.addOptions call initResolutions if necessary
 * (Closes #2656) no way to pass read options from protocol to format
 * (Closes #2751) Changes in languages: "es" and "ca".
 * (Closes #2814) SLDSelect control tests failing
 * (Closes #2815) Cluster Strategy should not destroy all features

Also:
 * Change examples to use OSGeo, rather than MetaCarta, servers.
 * Change copyright statements to correctly state joint copyright
   in the project, rather than MetaCarta copyright.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.10@10715 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2010-09-02 21:43:25 +00:00

71 lines
2.7 KiB
HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OpenLayers Restricted Extent Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="../lib/Firebug/firebug.js"></script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map = null;
var extent = new OpenLayers.Bounds(-180, -90, 180, 90);
function init() {
var options = {
restrictedExtent: extent
}
map = new OpenLayers.Map('map', options);
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0?",
{layers: 'basic'}
);
map.addLayers([wms]);
map.setCenter(extent, 1);
document.getElementById("toggle").checked = true;
}
function toggleRestrictedExtent() {
if(map.restrictedExtent == null) {
map.setOptions({restrictedExtent: extent});
} else {
map.setOptions({restrictedExtent: null});
}
}
</script>
</head>
<body onload="init()">
<h1 id="title">OpenLayers Restricted Extent Example</h1>
<p id="shortdesc">
Don't let users drag outside the map extent: instead, limit dragging such
that the extent of the layer is the maximum viewable area.
</p>
<div id="map" class="smallmap"></div>
<p>
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.
</p>
<p>
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.
</p>
<p>
<input type="checkbox" id="toggle" checked="checked"
onclick="toggleRestrictedExtent();" />
<label for="toggle">
Toggle restricted extent (to [-180, -90, 180, 90]).
</label>
</body>
</html>