Project

General

Profile

1
<html>
2
<head>
3
<title>Setting a visual Extent</title>
4
<script src="../lib/OpenLayers.js"></script>
5
</head>
6
<body>
7
<h1>Setting a Visual Extent</h1>
8
<p>
9
  Because the ability to set the map to a given extent is limited by the 
10
  current resolutions available, zoomToExtent will not always set the map to 
11
  exactly the right extent. In order to visually annotate the actual extent, 
12
  this example, will use the Boxes layer to visually describe the desired
13
  extent as well as setting the map extent.
14
</p>
15
  <div style="width:100%; height:75%" id="map"></div>
16
  <script defer="defer" type="text/javascript">
17
    var map = new OpenLayers.Map('map');
18
    var bounds = new OpenLayers.Bounds(-45,-45, 0, 45); 
19
    var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
20
        "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
21
    map.addLayer(wms);
22
    map.zoomToExtent(bounds);
23
    var boxes = new OpenLayers.Layer.Boxes("boxes");
24
    var box = new OpenLayers.Marker.Box(bounds);
25
    boxes.addMarker(box);
26
    map.addLayer(boxes);
27
  </script>
28
</body>
29
</html>
(23-23/35)