source: sandbox/jachym/openlayers/examples/layer-groups.html @ 4958

Last change on this file since 4958 was 4958, checked in by jachym, 9 years ago

Added new example with layer groups

File size: 3.2 KB
Line 
1<html xmlns="http://www.w3.org/1999/xhtml">
2  <head>
3    <style type="text/css">
4        #map {
5            width: 512px;
6            height: 512px;
7            border: 1px solid black;
8        }
9    </style>
10    <script src="../lib/OpenLayers.js"></script>
11    <script type="text/javascript">
12        // making this a global variable so that it is accessible for
13        // debugging/inspecting in Firebug
14        var map = null;
15
16        <!--
17        function init(){
18
19            map = new OpenLayers.Map('map');
20
21            var options = { 
22                            resolutions: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.00137329101],
23            };
24           
25            var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
26                "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'},
27                options); 
28
29            var options2 = { 
30                            resolutions: [0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.00137329101],
31                group:"Group1"
32                           
33            };
34            var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
35                "http://wms.jpl.nasa.gov/wms.cgi", 
36                {layers: "modis,global_mosaic"}, options2);
37
38            var dm_transit = new OpenLayers.Layer.WMS( "DM Solutions Transit",
39                "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
40                {layers: "rail,road",
41                 transparent: "true", format: "image/png"},
42                 {minResolution: 0.17578125,
43                  maxResolution: 0.703125,
44                  group:"WMS/Transit"});
45
46            var dm_wms = new OpenLayers.Layer.WMS( "DM Solutions Demo",
47                "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
48                {layers: "bathymetry,land_fn,park,drain_fn,drainage," +
49                         "fedlimit,popplace",
50                 transparent: "true", format: "image/png"},
51                 {minResolution: 0.17578125,
52                  maxResolution: 0.703125,
53                  });
54
55            var demis = new OpenLayers.Layer.WMS("Demis", 
56                "http://www2.demis.nl/mapserver/wms.asp",
57                {layers: "Borders", transparent:true},
58                {isBaseLayer:false, visibility:true, group: "WMS/Borders"});
59
60            var dm_borders = new OpenLayers.Layer.WMS( "DM Solutions Demo",
61                "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
62                {layers: "prov_bound",
63                 transparent: "true", format: "image/png"},
64                 {minResolution: 0.17578125,
65                  maxResolution: 0.703125,
66                  group: "WMS/Borders"
67                  });
68
69            map.addLayers([ol_wms, jpl_wms, dm_wms,dm_transit,dm_borders, demis]);
70            map.addControl(new OpenLayers.Control.LayerSwitcher());
71            // map.setCenter(new OpenLayers.LonLat(0, 0), 0);
72            map.zoomToMaxExtent();
73        }
74        // -->
75    </script>
76  </head>
77  <body onload="init()">
78    <table><tr><td>
79        <h1>OpenLayers Example</h1>
80    </td><td>
81        <h3 id="browserHeader"></h3>
82    </td></tr></table>
83    <div id="map"></div>
84  </body>
85</html>
Note: See TracBrowser for help on using the repository browser.