giving the overview example two maps

git-svn-id: http://svn.openlayers.org/trunk/openlayers@5114 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-11-05 17:41:39 +00:00
parent 2b55af61b9
commit 4fe97a92c6
+89 -40
View File
@@ -1,47 +1,96 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <html>
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd"> <head>
<html xmlns="http://www.w3.org/1999/xhtml"> <title>Overview Map Example</title>
<head> <script src="../lib/OpenLayers.js" type="text/javascript"></script>
<title>Overview Map Example</title> <style>
<script src="../lib/OpenLayers.js" type="text/javascript"></script> #map1 {
<style> width: 500px;
#map{ height: 300px;
width:100%; border: 1px solid gray;
height:500px; }
border:1px solid; #map2 {
} width: 500px;
</style> height: 300px;
</head> border: 1px solid gray;
<body> }
<div id="map"></div> </style>
<script defer="defer" type="text/javascript"> </head>
var map = new OpenLayers.Map('map'); <body>
// my city <div id="map1"></div>
var constantina = new OpenLayers.LonLat(-5.6165,37.8623); <p>The above map has an overview map control that is created with
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", the default options. Much like a regular map, the map contained by
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} ); the overview map control defaults to a geographic projection.</p>
var nasa_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic", <div id="map2"></div>
"http://wms.jpl.nasa.gov/wms.cgi", {layers: "modis,global_mosaic"} ); <p>The second map has an overview map control that is created with
non-default options. In this case, the mapOptions property of the
control has been set to use non-default projection related properties.
In addition, any other properties of the overview map control can be
set in this way.</p>
<script defer="defer" type="text/javascript">
map.addLayers([ // create the top map (with default overview map control)
nasa_wms, var map1 = new OpenLayers.Map('map1');
wms
]);
map.addControl(new OpenLayers.Control.LayerSwitcher()); var ol = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'}
);
var options = { var jpl = new OpenLayers.Layer.WMS(
layers: [wms.clone()], "NASA Global Mosaic",
minRatio: 8, "http://wms..nasa.gov/wms.cgi",
maxRatio: 128 {layers: "modis,global_mosaic"}
}; );
var overview = new OpenLayers.Control.OverviewMap(options);
map.addControl(overview); map1.addLayers([ol, jpl]);
map1.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(constantina, 4); // create an overview map control with the default options
var overview1 = new OpenLayers.Control.OverviewMap();
map1.addControl(overview1);
overview.maximizeControl(); map1.setCenter(new OpenLayers.LonLat(0, 0), 2);
</script>
</body> // expand the overview map control
overview1.maximizeControl();
// create the bottom map (with advanced overview map control)
var mapOptions = {
maxExtent: new OpenLayers.Bounds(33861, 717605, 330846, 1019656),
maxResolution: 296985/1024,
projection: "EPSG:2805",
units: "m"
};
var map2 = new OpenLayers.Map('map2', mapOptions);
var bos = new OpenLayers.Layer.WMS(
"Boston",
"http://boston.freemap.in/cgi-bin/mapserv",
{
map: '/www/freemap.in/boston/map/gmaps.map',
layers: 'border,water,roads,rapid_transit,buildings',
format: 'png'
}
);
map2.addLayers([bos]);
map2.addControl(new OpenLayers.Control.LayerSwitcher());
// create an overview map control with the default options
var controlOptions = {
mapOptions: mapOptions
}
var overview2 = new OpenLayers.Control.OverviewMap(controlOptions);
map2.addControl(overview2);
map2.setCenter(new OpenLayers.LonLat(182500, 868500), 3);
// expand the overview map control
overview2.maximizeControl();
</script>
</body>
</html> </html>