1 <html xmlns="http://www.w3.org/1999/xhtml">
3 <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
4 <link rel="stylesheet" href="style.css" type="text/css" />
5 <style type="text/css">
11 <script src="../lib/Firebug/firebug.js"></script>
12 <script src="../lib/OpenLayers.js"></script>
13 <script type="text/javascript">
16 OpenLayers.IMAGE_RELOAD_ATTEMPTS = 2;
17 OpenLayers.Util.onImageLoadErrorColor = "transparent";
19 var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}});
20 var doc, context, map;
24 maxExtent: new OpenLayers.Bounds(-130, 14, -60, 55)
26 map = new OpenLayers.Map("map", options);
28 var jpl = new OpenLayers.Layer.WMS(
30 "http://t1.hypercube.telascience.org/cgi-bin/landsat7",
33 maxExtent: new OpenLayers.Bounds(-130, 14, -60, 55),
40 var vmap = new OpenLayers.Layer.WMS(
42 "http://labs.metacarta.com/wms/vmap0",
45 maxExtent: new OpenLayers.Bounds(-130, 14, -60, 55),
52 var roads = new OpenLayers.Layer.WMS(
53 "Transportation Network",
54 "http://lioapp.lrc.gov.on.ca/cubeserv/cubeserv.pl",
55 {layers: "na_road:CCRS", transparent: "TRUE"},
58 maxExtent: new OpenLayers.Bounds(
59 -166.532, 4.05046, -0.206818, 70.287
61 displayInLayerSwitcher: false,
69 var nexrad = new OpenLayers.Layer.WMS(
71 "http://columbo.nrlssc.navy.mil/ogcwms/servlet/WMSServlet/AccuWeather_Maps.wms",
72 {layers: "3:1", transparent: "TRUE"},
75 maxExtent: new OpenLayers.Bounds(
76 -131.029495239, 14.5628967285,
77 -61.0295028687, 54.562896728
87 map.addLayers([jpl, vmap, roads, nexrad]);
88 map.addControl(new OpenLayers.Control.LayerSwitcher());
89 map.setCenter(new OpenLayers.LonLat(-95, 34.5), 1);
92 function readWMC(merge) {
93 var text = document.getElementById("wmc").value;
97 map = format.read(text, {map: map});
99 document.getElementById("wmc").value = err;
104 map = format.read(text, {map: "map"});
105 map.addControl(new OpenLayers.Control.LayerSwitcher());
107 document.getElementById("wmc").value = err;
112 function writeWMC(merge) {
114 var text = format.write(map);
115 document.getElementById("wmc").value = text;
117 document.getElementById("wmc").value = err;
123 <body onload="init()">
124 <h1 id="title">WMC Example</h1>
129 Shows parsing of Web Map Context documents.
131 <div id="map" class="smallmap"></div>
132 <button onclick="writeWMC();">write</button>
133 <button onclick="readWMC();">read as new map</button>
134 <button onclick="readWMC(true);">read and merge</button>
135 <textarea id="wmc">paste WMC doc here</textarea>
137 This is an example of parsing WMC documents. <br />
138 The format class has a layerOptions property, which can be used
139 to control the default options of the layer when it is created