3 <title>Setting a visual Extent</title>
4 <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
5 <link rel="stylesheet" href="style.css" type="text/css" />
6 <script src="../lib/OpenLayers.js"></script>
9 <h1 id="title">Setting a Visual Extent</h1>
11 Use a boxes layer to visually display the area of interest indicated by a user.
14 Because the ability to set the map to a given extent is limited by the
15 current resolutions available, zoomToExtent will not always set the map to
16 exactly the right extent. In order to visually annotate the actual extent,
17 this example, will use the Boxes layer to visually describe the desired
18 extent as well as setting the map extent.
20 <div style="width:100%; height:75%" id="map"></div>
21 <script defer="defer" type="text/javascript">
22 var map = new OpenLayers.Map('map');
23 var bounds = new OpenLayers.Bounds(-45,-45, 0, 45);
24 var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
25 "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
27 map.zoomToExtent(bounds);
28 var boxes = new OpenLayers.Layer.Boxes("boxes");
29 var box = new OpenLayers.Marker.Box(bounds);