Project

General

Profile

1
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
2
<html>
3
<head>
4
<title>
5
<a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008 Overview
6
</title>
7
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
8
<script>
9
function asd() {
10
	
11
		parent.document.title="MapPaneOL.js Overview";
12
	
13
}
14
</script>
15
</head>
16
<body bgcolor="white" onload="asd();">
17

    
18
<!-- ========== START OF NAVBAR ========== -->
19
<a name="navbar_top"><!-- --></a>
20
<table border="0" width="100%" cellpadding="1" cellspacing="0">
21
<tr>
22
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
23
<a name="navbar_top_firstrow"><!-- --></a>
24
<table border="0" cellpadding="0" cellspacing="3">
25
  <tr align="center" valign="top">
26
  
27
  
28
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
29
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
30
  
31

    
32
  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
33
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
34
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
35
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
36
  </tr>
37
</table>
38
</td>
39
<td bgcolor="#EEEEFF" align="right" valign="top">
40
<em>
41
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
42
</td>
43
</tr>
44

    
45
<tr>
46
<td bgcolor="white" class="NavBarCell2"><font size="-2">
47
&nbsp;PREV&nbsp;
48
&nbsp;NEXT</font></td>
49
<td bgcolor="white" class="NavBarCell2"><font size="-2">
50
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
51
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
52
&nbsp;&nbsp;
53
<script>
54
  <!--
55
  if(window==top) {
56
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
57
  }
58
  //-->
59
</script>
60
<noscript>
61
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
62
</noscript>
63
</font></td>
64
</tr>
65
</table>
66
<!-- =========== END OF NAVBAR =========== -->
67

    
68
<hr>
69
<center>
70
	
71
	   <h2>MapPaneOL.js</h2>
72
	
73
</center>
74

    
75
	
76

    
77

    
78
<h4>Summary</h4>
79
<p>
80
	
81
		No overview generated for 'MapPaneOL.js'<BR/><BR/>
82
	
83
</p>
84

    
85
<hr>
86

    
87

    
88
    <table border="1" cellpadding="3" cellspacing="0" width="100%">
89
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
90
    <td colspan=2><font size="+2">
91
    
92
        <b>Class Summary</b>
93
    
94
    </font></td>
95
    </tr>
96
    
97
    <tr bgcolor="white" class="TableRowColor">
98
    <td width="15%"><b><a href="MapPaneOL.html">MapPaneOL</a></b></td>
99
    <td>&nbsp;</td>
100
    </tr>
101
    
102
    </table>
103
    <hr/> 
104

    
105

    
106
<!-- ========== METHOD SUMMARY =========== -->
107

    
108
	<a name="method_summary"><!-- --></a>
109
	<table border="1" cellpadding="3" cellspacing="0" width="100%">
110
		<tr bgcolor="#CCCCFF" class="TableHeadingColor">
111
			<td colspan=2>
112
				<font size="+2">
113
					<b>Method Summary</b>
114
				</font>
115
			</td>
116
		</tr>
117
	
118
		
119
		   <tr bgcolor="white" class="TableRowColor">
120
		      <td align="right" valign="top" width="1%">
121
			 <font size="-1">
122
			    <code>static&nbsp;Object</code>
123
			 </font>
124
		      </td>
125
		      <td>
126
			 <code>
127
			    <b>
128
			       <a href="GLOBALS.html#imageLoaded">imageLoaded</a></b>()
129
			 </code>
130
			 <br>
131
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
132
			 
133
		      </td>
134
		   </tr>
135
		
136
	
137
	</table>
138
    <p>
139

    
140
<!-- ========== END METHOD SUMMARY =========== -->
141

    
142

    
143
        <pre class="sourceview"><span class="comment">/*
144
Author:       Cameron Shorter cameronAtshorter.net
145
License:      LGPL as per: http://www.gnu.org/copyleft/lesser.html
146

    
147
$Id: MapPaneOL.js 3935 2008-03-25 13:58:02Z ahocevar $
148
*/</span>
149
<span class="comment">
150
// Ensure this object's dependancies are loaded.</span>
151
loadCss(<span class="literal">"openlayers/style.css"</span>);
152
mapbuilder.loadScript(baseDir+<span class="literal">"/util/openlayers/OpenLayers.js"</span>);
153
mapbuilder.loadScript(baseDir+<span class="literal">"/util/Util.js"</span>);
154
mapbuilder.loadScript(baseDir+<span class="literal">"/widget/WidgetBase.js"</span>);
155
mapbuilder.loadScript(baseDir+<span class="literal">"/tool/Extent.js"</span>);
156
<span class="comment">/**
157
 * Widget to render a map from an OGC context document.  The layers are
158
 * rendered using http://openlayers.org .
159
 * <span class="attrib">@constructor</span>
160
 * <span class="attrib">@base</span> WidgetBase
161
 * <span class="attrib">@param</span> widgetNode  The widget's XML object node from the configuration document.
162
 * <span class="attrib">@param</span> model       The model object that this widget belongs to.
163
 */</span>
164
<span class="reserved">function</span> MapPaneOL(widgetNode, model) {
165
  WidgetBase.apply(<span class="reserved">this</span>,new Array(widgetNode, model));
166

    
167
  OpenLayers.ImgPath = config.skinDir + <span class="literal">'/images/openlayers/'</span>;
168
  OpenLayers.ProxyHost = config.proxyUrl+<span class="literal">"/?url="</span>;
169
<span class="comment">  
170

    
171
  // replacement for deprecated MapContainerBase</span>
172
  <span class="reserved">this</span>.containerNodeId = <span class="reserved">this</span>.htmlTagId;
173
  model.containerModel = <span class="reserved">this</span>.model;
174
<span class="comment">
175
  //Make sure the Extent is attached to the context and initialized</span>
176
  <span class="reserved">if</span>(!<span class="reserved">this</span>.model.extent){
177
    <span class="reserved">this</span>.model.extent = new Extent (<span class="reserved">this</span>.model);
178
    <span class="reserved">this</span>.model.addFirstListener( <span class="literal">"loadModel"</span>, <span class="reserved">this</span>.model.extent.firstInit, <span class="reserved">this</span>.model.extent );
179
  }
180

    
181
  <span class="comment">/**
182
   * For tiled wms layers: Overlap of map tiles in pixels. Useful for
183
   * preventing rendering artefacts at tile edges. Recommended values:
184
   * 0-15, default is 0 (no gutter at all).
185
   */</span>
186
  <span class="reserved">this</span>.tileGutter = <span class="reserved">this</span>.getProperty(<span class="literal">"mb:tileGutter"</span>, 0);
187
  
188
  <span class="comment">/**
189
   * For tiled wms layers: how many rows of tiles should be preloaded
190
   * outside the visible map? Large values mean slow loading, small
191
   * ones mean longer delays when panning. Recommended values: 1-3,
192
   * default is 2.
193
   */</span>
194
  <span class="reserved">this</span>.tileBuffer = parseInt(<span class="reserved">this</span>.getProperty(<span class="literal">"mb:tileBuffer"</span>, 2));
195
  
196
   <span class="comment">/**
197
    * For WMS layers: should they be regarded as normal WMS layers, 
198
    * with a single tile for the entire boundingbox or as a tiled
199
    * WMS layer
200
   */</span>
201
  <span class="reserved">this</span>.singleTile = Mapbuilder.parseBoolean(<span class="reserved">this</span>.getProperty(<span class="literal">"mb:singleTile"</span>, true));
202
  
203
  <span class="comment">/**
204
   * For tiled wms layers: how many pixels should the size of one tile
205
   * be? Default is 256.
206
   */</span>
207
  <span class="reserved">this</span>.tileSize = parseInt(<span class="reserved">this</span>.getProperty(<span class="literal">"mb:tileSize"</span>, 256));
208
  
209
  <span class="comment">/**
210
   * For WMS on top of Google Maps you need to reproject the WMS image. This will stretch
211
   * the WMS images to fit the odd sized google tiles. Default is false
212
   */</span>
213
  <span class="reserved">this</span>.imageReproject = Mapbuilder.parseBoolean(
214
      <span class="reserved">this</span>.getProperty(<span class="literal">"mb:imageReproject"</span>, false));
215
  
216
  <span class="comment">/**
217
   * for untiled wms layers: how many times should the map image be
218
   * larger than the visible map. Large values mean slow loading, small
219
   * ones mean many reloads when panning. Recommended values: 1-3,
220
   * default is 2.
221
   */</span>
222
  <span class="reserved">this</span>.imageBuffer = parseInt(<span class="reserved">this</span>.getProperty(<span class="literal">"mb:imageBuffer"</span>, 2));
223
  
224
  <span class="comment">/**
225
   * Should layers also be rendered outside the map extent? Default is false.
226
   */</span>
227
  <span class="reserved">this</span>.displayOutsideMaxExtent = Mapbuilder.parseBoolean(
228
      <span class="reserved">this</span>.getProperty(<span class="literal">"mb:displayOutsideMaxExtent"</span>, false));
229
  
230
  <span class="comment">/**
231
   * Number of layers that are currently being loaded
232
   */</span>
233
  <span class="reserved">this</span>.loadingLayers = 0;
234

    
235
  <span class="comment">/**
236
   * Called after a feature has been added to a WFS.  This function triggers
237
   * the WMS basemaps to be redrawn.  A timestamp param is added to the URL
238
   * to ensure the basemap image is not cached.
239
   * This function is triggered by the refreshWmsLayers event. If this event
240
   * is fired with a &lt;layerId&gt; as param, only that layer will be refreshed.
241
   * <span class="attrib">@param</span> objRef reference to this widget
242
   */</span>
243
  <span class="reserved">this</span>.refreshWmsLayers = <span class="reserved">function</span>(objRef) {
244
    var layerId = objRef.model.getParam(<span class="literal">"refreshWmsLayers"</span>);
245
    var uniqueId = (new Date()).getTime();
246
    var layers = layerId ?
247
        [objRef.getLayer(objRef, layerId)] :
248
        objRef.model.map.layers;
249
    <span class="reserved">for</span> (var i in layers) {
250
      <span class="reserved">if</span> (layers[i].CLASS_NAME.indexOf(<span class="literal">'OpenLayers.Layer.WMS'</span>) == 0) {
251
        layers[i].mergeNewParams({uniqueId: uniqueId});
252
      }
253
    }
254
  }
255
  <span class="reserved">this</span>.model.addListener(<span class="literal">"refreshWmsLayers"</span>,<span class="reserved">this</span>.refreshWmsLayers,<span class="reserved">this</span>);
256

    
257
  <span class="reserved">this</span>.model.addListener(<span class="literal">"refresh"</span>,<span class="reserved">this</span>.paint, <span class="reserved">this</span>);
258
  <span class="reserved">this</span>.model.addFirstListener(<span class="literal">"newModel"</span>, <span class="reserved">this</span>.clear, <span class="reserved">this</span>);
259
  <span class="reserved">this</span>.model.addListener(<span class="literal">"hidden"</span>,<span class="reserved">this</span>.hidden, <span class="reserved">this</span>);
260
  <span class="reserved">this</span>.model.addListener(<span class="literal">"addLayer"</span>,<span class="reserved">this</span>.addLayer, <span class="reserved">this</span>);
261
  <span class="reserved">this</span>.model.addListener(<span class="literal">"deleteLayer"</span>,<span class="reserved">this</span>.deleteLayer, <span class="reserved">this</span>);
262
  <span class="reserved">this</span>.model.addListener(<span class="literal">"moveLayerUp"</span>,<span class="reserved">this</span>.moveLayerUp, <span class="reserved">this</span>);
263
  <span class="reserved">this</span>.model.addListener(<span class="literal">"moveLayerDown"</span>,<span class="reserved">this</span>.moveLayerDown, <span class="reserved">this</span>);
264
  <span class="reserved">this</span>.model.addListener(<span class="literal">"opacity"</span>,<span class="reserved">this</span>.setOpacity,<span class="reserved">this</span>);
265
  <span class="reserved">this</span>.model.addListener(<span class="literal">"bbox"</span>, <span class="reserved">this</span>.zoomToBbox, <span class="reserved">this</span>);
266
<span class="comment">  //this.model.addListener( "zoomOut", this.zoomOut, this );</span>
267
<span class="comment">  //this.model.addListener( "zoomIn", this.zoomIn, this );</span>
268
<span class="comment">  // this.model.addListener( "zoomToMaxExtent", this.zoomToMaxExtent, this );</span>
269
<span class="comment"> //this.model.addFirstListener("loadModel",this.paint,this);</span>
270

    
271
}
272

    
273
<span class="comment">/**
274
 * Render the widget.
275
 * <span class="attrib">@param</span> objRef Pointer to widget object.
276
 */</span>
277
MapPaneOL.<span class="reserved">prototype</span>.paint = <span class="reserved">function</span>(objRef, refresh) {
278
<span class="comment">  
279
  // Create an OpenLayers map</span>
280
<span class="comment">
281
  //Test if context exist</span>
282
  <span class="reserved">if</span>(objRef.model.doc.selectSingleNode(<span class="literal">"//wmc:OWSContext"</span>))
283
    objRef.context=<span class="literal">"OWS"</span>;
284
  <span class="reserved">else</span> <span class="reserved">if</span>(objRef.model.doc.selectSingleNode(<span class="literal">"//wmc:ViewContext"</span>))
285
    objRef.context=<span class="literal">"View"</span>;
286
  <span class="reserved">else</span>
287
    alert(mbGetMessage(<span class="literal">"noContextDefined"</span>));
288

    
289
  var proj=objRef.model.proj;
290
<span class="comment">
291
  //maxExtent</span>
292
  var maxExtent=null;
293
  maxExtent=objRef.getProperty(<span class="literal">"mb:maxExtent"</span>);
294
  maxExtent=(maxExtent)?maxExtent.split(<span class="literal">" "</span>):null;
295
<span class="comment">  // If the maxExtentis not specified in the config</span>
296
<span class="comment">  // calculate it from the BBox  in the Context.</span>
297
  <span class="reserved">if</span>(!maxExtent){
298
    maxExtent=objRef.model.getBoundingBox();
299
  }
300
  maxExtent=(maxExtent)?new OpenLayers.Bounds(maxExtent[0],maxExtent[1],maxExtent[2],maxExtent[3]):null;
301
  <span class="reserved">if</span>(maxExtent==null)alert(mbGetMessage(<span class="literal">"noBboxInContext"</span>));
302
<span class="comment">
303
  //maxResolution</span>
304
  var maxResolution=null;
305
  maxResolution=objRef.getProperty(<span class="literal">"mb:maxResolution"</span>);
306
  maxResolution=(maxResolution) ? parseFloat(maxResolution) : <span class="literal">"auto"</span>;
307
<span class="comment">
308
  //minResolution</span>
309
  var minResolution=null;
310
  minResolution=objRef.getProperty(<span class="literal">"mb:minResolution"</span>);
311
  minResolution=(minResolution) ? parseFloat(minResolution) : undefined;
312
<span class="comment">  
313
  //transitionEffect</span>
314
  objRef.transitionEffect = objRef.getProperty(<span class="literal">"mb:transitionEffect"</span>, undefined);
315
<span class="comment">  
316
  //units</span>
317
  var units = proj.getUnits() == <span class="literal">'meters'</span> ? <span class="literal">'m'</span> : proj.getUnits();
318
<span class="comment">  
319
  //resolutions</span>
320
<span class="comment">  //TBD: if resolutions is both set here and for the baselayer and they are different weird things may happen</span>
321
<span class="comment">  //     this needs to be solved</span>
322
  var resolutions=objRef.getProperty(<span class="literal">"mb:resolutions"</span>);
323
  resolutions = resolutions ? resolutions.split(<span class="literal">","</span>) : null;
324
  <span class="reserved">if</span> (resolutions) {
325
    <span class="reserved">for</span> (var r=0; r&lt;resolutions.length; r++) {
326
      resolutions[r] = parseFloat(resolutions[r]);
327
    }
328
  }
329
<span class="comment">
330
  //fixed scales - overrides resolutions</span>
331
  var scales = objRef.getProperty(<span class="literal">"mb:scales"</span>);
332
  <span class="reserved">if</span>(scales){
333
    scales = scales.split(<span class="literal">","</span>);
334
    resolutions = new Array();
335
    <span class="reserved">for</span> (var s=0; s&lt;scales.length; s++) {
336
      resolutions.push(OpenLayers.Util.getResolutionFromScale(scales[s], units));
337
    }
338
  }
339
  <span class="reserved">if</span>(resolutions){
340
    objRef.model.extent.setZoomLevels(true,resolutions);
341
  }
342
  <span class="reserved">else</span> objRef.model.extent.setZoomLevels(false);
343
<span class="comment">
344
  //get the output DIV and set it to context-size</span>
345
  var node = document.getElementById(objRef.containerNodeId);
346
  var fixedSize = Mapbuilder.parseBoolean(objRef.getProperty(<span class="literal">"mb:fixedSize"</span>, false));
347
  <span class="reserved">if</span>(fixedSize){
348
    node.style.width = objRef.model.getWindowWidth()+<span class="literal">"px"</span>;
349
    node.style.height = objRef.model.getWindowHeight()+<span class="literal">"px"</span>;
350
  }
351
<span class="comment">  
352
  //default map options</span>
353
  var mapOptions = {
354
        controls:[],
355
        projection: proj,
356
        units: units,
357
        fractionalZoom: true,
358
        maxExtent: maxExtent,
359
        maxResolution: maxResolution,
360
        minResolution: minResolution,
361
        resolutions: resolutions,
362
        theme: null, // we have the theme loaded by Mapbuilder
363
        destroy: <span class="reserved">function</span>(destroy){
364
                   <span class="reserved">if</span> (destroy != true) {
365
                     <span class="reserved">this</span>.mbMapPane.model.setParam(<span class="literal">"newModel"</span>, true);
366
                   } <span class="reserved">else</span> {
367
                     <span class="reserved">this</span>.mbMapPane = null;
368
                     <span class="reserved">this</span>.mbCursor = null;
369
                     OpenLayers.Map.<span class="reserved">prototype</span>.destroy.apply(<span class="reserved">this</span>, arguments);
370
                     <span class="reserved">this</span>.layerContainerDiv = null;
371
                     <span class="reserved">this</span>.baseLayer = null;
372
                   }}
373
      };
374

    
375
  <span class="reserved">if</span> (!objRef.model.map) {
376
    objRef.model.map = new OpenLayers.Map(node, mapOptions);
377
<span class="comment">
378
    // Increase hight of Control layers to allow for lots of layers.</span>
379
    objRef.model.map.Z_INDEX_BASE.Control=10000;
380
    var baseLayer = null;
381
<span class="comment">    
382
    //If we have an OWSContext and we have a BaseLayer we need to use this layer</span>
383
<span class="comment">    //for more information have a look at http://docs.codehaus.org/display/MAP/Using+Google-layers</span>
384
    <span class="reserved">if</span>(objRef.context==<span class="literal">"OWS"</span>&amp;&amp;objRef.model.getBaseLayer()){
385
      var baseLayerNode = objRef.model.getBaseLayer();
386
<span class="comment">     
387
      //overrule the SRS in the Context with the one from the BaseLayer</span>
388
      var baseSrs = baseLayerNode.selectSingleNode(<span class="literal">"ows:TileSet/ows:SRS"</span>);
389
      <span class="reserved">if</span>(baseSrs) objRef.model.setSRS(getNodeValue(baseSrs));
390
<span class="comment">      //overrule the units in the Context with the updated SRS units</span>
391
      units = proj.getUnits() == <span class="literal">'meters'</span> ? <span class="literal">'m'</span> : proj.getUnits();
392
<span class="comment">      //overrule the boundingbox in the Context with the maxExtent from the BaseLayer</span>
393
      var maxExtentNode = baseLayerNode.selectSingleNode(<span class="literal">"ows:TileSet/ows:BoundingBox"</span>);
394
      <span class="reserved">if</span>(maxExtentNode) maxExtent = new OpenLayers.Bounds(maxExtentNode.selectSingleNode(<span class="literal">'@minx'</span>).nodeValue,maxExtentNode.selectSingleNode(<span class="literal">'@miny'</span>).nodeValue,maxExtentNode.selectSingleNode(<span class="literal">'@maxx'</span>).nodeValue,maxExtentNode.selectSingleNode(<span class="literal">'@maxy'</span>).nodeValue);
395
<span class="comment">      //overrule resolutions in the Context with the one from BaseLayer</span>
396
<span class="comment">      //<span class="attrib">@TODO</span>: check if the firstChild is really needed</span>
397
      var resolutions =baseLayerNode.selectSingleNode(<span class="literal">"ows:TileSet/ows:Resolutions"</span>);
398
      resolutions = resolutions ? getNodeValue(resolutions).split(<span class="literal">","</span>) : null;
399
      <span class="reserved">if</span> (resolutions) {
400
        <span class="reserved">for</span> (var r=0; r&lt;resolutions.length; r++) {
401
           resolutions[r] = parseFloat(resolutions[r]);
402
        }
403
      }
404
<span class="comment">      //overrule tileSize in the Context with the one from the BaseLayer</span>
405
<span class="comment">      //right now we only support square tiles which are defined by their width:		  </span>
406
      var tileSize =baseLayerNode.selectSingleNode(<span class="literal">"ows:TileSet/ows:Width"</span>);
407
      <span class="reserved">if</span>(tileSize) objRef.tileSize = parseInt(tileSize.nodeValue);
408
<span class="comment">      //check if there's a format defined for the BaseLayer</span>
409
      var format = baseLayerNode.selectSingleNode(<span class="literal">"ows:TileSet/ows:Format"</span>);
410
      <span class="reserved">if</span>(format) format = format.nodeValue;
411
<span class="comment">      
412
      //Initialising the baseLayer</span>
413
<span class="comment">      // Test service of the baseLayer</span>
414
      var service=baseLayerNode.selectSingleNode(<span class="literal">"wmc:Server/@service"</span>);
415
      service=(service)?service.nodeValue:<span class="literal">""</span>;
416
<span class="comment">      // Test title of the baseLayer</span>
417
      var title=Mapbuilder.getProperty(baseLayerNode, <span class="literal">"wmc:Title"</span>, <span class="literal">""</span>);
418
<span class="comment">      // Get the name of the baseLayer</span>
419
      var baseLayerName = Mapbuilder.getProperty(baseLayerNode, <span class="literal">"wmc:Name"</span>, <span class="literal">""</span>);
420
<span class="comment">      // get the layer-type of the BaseLayer (this allows specifying if is is a arial,road or hybrid map)</span>
421
      var baseLayerType = Mapbuilder.getProperty(baseLayerNode, <span class="literal">"ows:TileSet/ows:Layers"</span>, <span class="literal">"hybrid"</span>);
422
<span class="comment">      // it might be that the baseLayer is a WMS so we need to fetch the url</span>
423
      var href=Mapbuilder.getProperty(baseLayerNode, <span class="literal">"wmc:Server/wmc:OnlineResource/@xlink:href"</span>, <span class="literal">""</span>);
424
      
425
      var baseLayerOptions = {
426
              units: units,
427
              projection: proj,
428
              maxExtent: maxExtent,
429
             
430
              alpha: false,            //option <span class="reserved">for</span> png transparency with ie6
431
              isBaseLayer: true,
432
              displayOutsideMaxExtent: objRef.displayOutsideMaxExtent,
433
              ratio: 1
434
              
435
         };
436
         
437
      switch(service){
438
<span class="comment">        // WMS Layer (Untiled)</span>
439
        case <span class="literal">"OGC"</span>:
440
        case <span class="literal">"WMS"</span>:
441
        case <span class="literal">"wms"</span>:
442
        case <span class="literal">"OGC:WMS"</span>:
443
          
444
          baseLayerOptions.ratio = objRef.imageBuffer;
445
    
446
          var params = new Array();
447

    
448
         
449
         baseLayer= new OpenLayers.Layer.WMS(title,href,{
450
              layers: baseLayerName,
451
              format: format
452
              },
453
            baseLayerOptions
454
          );
455
        break;
456
<span class="comment">    
457
        // WMS-C Layer (Tiled)</span>
458
        case <span class="literal">"WMS-C"</span>:
459
        case <span class="literal">"OGC:WMS-C"</span>:
460
          baseLayerOptions.gutter = objRef.tileGutter;
461
          baseLayerOptions.buffer = objRef.tileBuffer;
462
          baseLayerOptions.tileSize = new OpenLayers.Size(objRef.tileSize, objRef.tileSize);
463
          
464
          baseLayer= new OpenLayers.Layer.WMS(title,href,{
465
              layers: baseLayerName,
466
              format: format
467
            },
468
            baseLayerOptions
469
          );
470
          objRef.model.map.fractionalZoom = false;
471
        break;
472
    
473
        case <span class="literal">"GMAP"</span>:
474
        case <span class="literal">"Google"</span>:       
475
          <span class="reserved">if</span>(maxExtent) baseLayerOptions.maxExtent=maxExtent;
476
<span class="comment">          //check if we have spherical projection</span>
477
          var sphericalMercator = (objRef.model.getSRS()==<span class="literal">'EPSG:900913'</span>)?true:false;
478
<span class="comment">          //check if we have a layertype</span>
479
          switch(baseLayerType){
480
            case <span class="literal">"aerial"</span>:
481
            case <span class="literal">"satellite"</span>:            
482
              baseLayerType=G_SATELLITE_MAP;
483
            break;
484
            case <span class="literal">"road"</span>:
485
            case <span class="literal">"normal"</span>:            
486
              baseLayerType=G_NORMAL_MAP;
487
            break;
488
            default:
489
              baseLayerType=G_HYBRID_MAP;
490
          }
491
          baseLayer = new OpenLayers.Layer.Google( baseLayerName , {type: baseLayerType, minZoomLevel: 0, maxZoomLevel:19, sphericalMercator: sphericalMercator, maxResolution: 156543.0339 }, baseLayerOptions );
492
          objRef.model.map.numZoomLevels = 20;
493
          objRef.model.map.fractionalZoom = false;
494
        break;
495
    
496
        case <span class="literal">"YMAP"</span>:
497
        case <span class="literal">"Yahoo"</span>:
498
<span class="comment">          //Yahoo-layer doesn't support layerTypes</span>
499
          <span class="reserved">if</span>(maxExtent) baseLayerOptions.maxExtent=maxExtent;
500
<span class="comment">          //check if we have spherical projection</span>
501
          var sphericalMercator = (objRef.model.getSRS()==<span class="literal">'EPSG:900913'</span>)?true:false;          
502
          baseLayer = new OpenLayers.Layer.Yahoo(  baseLayerName , { maxZoomLevel:21, sphericalMercator: sphericalMercator }, baseLayerOptions );
503
          objRef.model.map.fractionalZoom = false;
504
        break;
505
    
506
        case <span class="literal">"VE"</span>:
507
        case <span class="literal">"Microsoft"</span>:
508
          <span class="reserved">if</span>(maxExtent) baseLayerOptions.maxExtent=maxExtent;
509
<span class="comment">          //check if we have spherical projection</span>
510
          var sphericalMercator = (objRef.model.getSRS()==<span class="literal">'EPSG:900913'</span>)?true:false;
511
<span class="comment">          //check if we have a layertype</span>
512
          switch(baseLayerType){
513
            case <span class="literal">"aerial"</span>:
514
            case <span class="literal">"satellite"</span>:
515
              baseLayerType=VEMapStyle.Aerial;
516
            break;
517
            case <span class="literal">"road"</span>:
518
            case <span class="literal">"normal"</span>:
519
              baseLayerType=VEMapStyle.Road;
520
            break;
521
            default:
522
              baseLayerType=VEMapStyle.Hybrid;
523
          }
524
          baseLayer = new OpenLayers.Layer.VirtualEarth( baseLayerName,{minZoomLevel: 0, maxZoomLevel: 21,type: baseLayerType});
525
          objRef.model.map.fractionalZoom = false;
526
        break;
527
    
528
        case <span class="literal">"MultiMap"</span>:
529
           <span class="reserved">if</span>(maxExtent) baseLayerOptions.maxExtent=maxExtent;
530
<span class="comment">           //check if we have spherical projection</span>
531
          var sphericalMercator = (objRef.model.getSRS()==<span class="literal">'EPSG:900913'</span>)?true:false;          
532
          baseLayer = new OpenLayers.Layer.MultiMap( baseLayerName , { maxZoomLevel:21, sphericalMercator: sphericalMercator }, baseLayerOptions );
533
          objRef.model.map.fractionalZoom = false;
534
        break;
535
        default:
536
          alert(mbGetMessage(<span class="literal">"layerTypeNotSupported"</span>, service));
537
        }
538
    }
539
<span class="comment">    //Otherwise we will just use a bogus WMS layer as BaseLayer</span>
540
    <span class="reserved">else</span> {
541
      var baseLayerOptions = {
542
              units: units,
543
              projection: proj.srsCode,
544
              maxExtent: maxExtent,
545
              maxResolution: maxResolution,  //<span class="literal">"auto"</span> <span class="reserved">if</span> not defined in the context
546
              minResolution: minResolution,
547
              resolutions: resolutions,
548
              alpha: false,            //option <span class="reserved">for</span> png transparency with ie6
549
              isBaseLayer: true,
550
              displayOutsideMaxExtent: objRef.displayOutsideMaxExtent,
551
              ratio: 1,
552
              singleTile: true,
553
              transitionEffect: objRef.transitionEffect,
554
              visibility: false,
555
              moveTo: <span class="reserved">function</span>(){<span class="reserved">return</span> true}
556
         };
557
      baseLayer = new OpenLayers.Layer.WMS(<span class="literal">"baselayer"</span>,
558
              config.skinDir+<span class="literal">"/images/openlayers/blank.gif"</span>, null, baseLayerOptions);
559
      
560
    }
561
    objRef.model.map.addLayer(baseLayer); 
562
  }
563
  <span class="reserved">else</span> {
564
    objRef.deleteAllLayers(objRef);
565
  }
566
    
567
  var layers = objRef.model.getAllLayers();
568
  <span class="reserved">if</span> (!objRef.oLlayers){
569
    objRef.oLlayers = {};
570
  }
571

    
572
  <span class="reserved">for</span> (var i=0;i&lt;=layers.length-1;i++){
573
    objRef.addLayer(objRef,layers[i]);
574
  }
575
  var bbox=objRef.model.getBoundingBox();
576
<span class="comment">
577
  // set objRef as attribute of the OL map, so we have a reference</span>
578
<span class="comment">  // to MapPaneOL available when handling OpenLayers events.</span>
579
  objRef.model.map.mbMapPane = objRef;
580
<span class="comment">
581
  // register OpenLayers event to keep the context updated</span>
582
  objRef.model.map.events.register(<span class="literal">'moveend'</span>, objRef.model.map, objRef.updateContext);
583
<span class="comment">  // register OpenLayers event to do updates onmouseup</span>
584
  objRef.model.map.events.register(<span class="literal">'mouseup'</span>, objRef.model.map, objRef.updateMouse);
585
  
586
  objRef.model.callListeners(<span class="literal">"bbox"</span>);
587
  
588
}
589

    
590
<span class="comment">/**
591
 * remove OpenLayers events and layers
592
 * <span class="attrib">@param</span> objRef reference to this widget
593
 */</span>
594
MapPaneOL.<span class="reserved">prototype</span>.clear = <span class="reserved">function</span>(objRef) {
595
  <span class="reserved">if</span> (objRef.model.map) {
596
    OpenLayers.Event.stopObservingElement(window);
597
    objRef.model.map.destroy(true);
598
    objRef.model.map = null;
599
    objRef.oLlayers = {};
600
  }
601
}
602

    
603
<span class="comment">/**
604
 * Event handler to keep the modelStatus updated when an OpenLayers layer
605
 * starts loading.
606
 * <span class="attrib">@param</span> e OpenLayers event
607
 */</span>
608
MapPaneOL.<span class="reserved">prototype</span>.increaseLoadingLayers = <span class="reserved">function</span>(e) {
609
  ++<span class="reserved">this</span>.loadingLayers;
610
  var message = mbGetMessage((<span class="reserved">this</span>.loadingLayers&gt;1) ? <span class="literal">"loadingLayers"</span> : <span class="literal">"loadingLayer"</span>,
611
    <span class="reserved">this</span>.loadingLayers);
612
  <span class="reserved">this</span>.model.setParam(<span class="literal">"modelStatus"</span>, message);
613
}
614

    
615
<span class="comment">/**
616
 * Event handler to keep the modelStatus updated when an OpenLayers layer
617
 * finished loading.
618
 * <span class="attrib">@param</span> e OpenLayers event
619
 */</span>
620
MapPaneOL.<span class="reserved">prototype</span>.decreaseLoadingLayers = <span class="reserved">function</span>(e) {
621
  --<span class="reserved">this</span>.loadingLayers;
622
  var message = <span class="reserved">this</span>.loadingLayers &gt; 0 ?
623
          mbGetMessage((<span class="reserved">this</span>.loadingLayers&gt;1) ? <span class="literal">"loadingLayers"</span> : <span class="literal">"loadingLayer"</span>,
624
                  <span class="reserved">this</span>.loadingLayers) :
625
          null;
626
  <span class="reserved">this</span>.model.setParam(<span class="literal">"modelStatus"</span>, message);
627
}
628

    
629
<span class="comment">/**
630
 * Event handler to keep the Mapbuilder context updated. It also
631
 * sets the map cursor to the previously stored value.
632
 * This is called by OpenLayers.
633
 * <span class="attrib">@param</span> e OpenLayers event
634
 */</span>
635
MapPaneOL.<span class="reserved">prototype</span>.updateContext = <span class="reserved">function</span>(e) {
636
<span class="comment">  // get objRef from the event originator object (e.object),</span>
637
<span class="comment">  // where it was stored as mbPane property by paint().</span>
638
  var objRef = e.object.mbMapPane;
639

    
640
  var bboxOL = objRef.model.map.getExtent().toBBOX().split(<span class="literal">','</span>);
641
  var ul = new Array(bboxOL[0],bboxOL[3]);
642
  var lr = new Array(bboxOL[2],bboxOL[1]);
643

    
644
  <span class="reserved">if</span>(objRef.model.getWindowWidth()!=e.element.offsetWidth)
645
    objRef.model.setWindowWidth(e.element.offsetWidth);
646
  <span class="reserved">if</span>(objRef.model.getWindowHeight()!=e.element.offsetHeight)
647
    objRef.model.setWindowHeight(e.element.offsetHeight);	
648

    
649
  var currentAoi = objRef.model.getParam(<span class="literal">'aoi'</span>);
650
  var newAoi = new Array(ul, lr);
651
  <span class="reserved">if</span> (!currentAoi || currentAoi.toString() != newAoi.toString()) {
652
    objRef.model.setBoundingBox( new Array(ul[0], lr[1], lr[0], ul[1]) );
653
    objRef.model.extent.setSize(objRef.model.map.getResolution());
654
    objRef.model.setParam(<span class="literal">"aoi"</span>, newAoi);
655
  }
656
}
657

    
658
<span class="comment">/**
659
 * Restore the map cursor stored by buttons. This has to be done
660
 * in an OpenLayers mouseup event, because the mouseup event
661
 * in OpenLayers resets the cursor to default.
662
 * <span class="attrib">@param</span> e OpenLayers event
663
 */</span>
664
MapPaneOL.<span class="reserved">prototype</span>.updateMouse = <span class="reserved">function</span>(e) {
665
<span class="comment">  // get objRef from the event originator object (e.object),</span>
666
<span class="comment">  // where it was stored as mbPane property by paint().</span>
667
  var objRef = e.object.mbMapPane;
668
<span class="comment">
669
  // update map pane cursor</span>
670
  <span class="reserved">if</span> (objRef.model.map.mbCursor) {
671
    objRef.model.map.div.style.cursor = objRef.model.map.mbCursor;
672
  }
673
}
674

    
675
<span class="comment">/**
676
 * Zoom to the current Bounding Box.
677
 * <span class="attrib">@param</span> objRef reference to this widget
678
 */</span>
679
MapPaneOL.<span class="reserved">prototype</span>.zoomToBbox = <span class="reserved">function</span>(objRef) {
680
  <span class="reserved">if</span> (objRef.model.map) {
681
    var bbox = objRef.model.getBoundingBox();
682
    var displayBbox = [];
683
    var extent = objRef.model.map.getExtent();
684
    <span class="reserved">if</span> (extent) {
685
      displayBbox = extent.toBBOX();
686
    }
687
<span class="comment">    // only perform zoom operation if not already at bbox</span>
688
    <span class="reserved">if</span> (bbox.toString() != displayBbox.toString()) {
689
      objRef.model.map.zoomToExtent(new OpenLayers.Bounds(bbox[0],bbox[1],bbox[2],bbox[3]));
690
    }
691
  }
692
}
693

    
694
<span class="comment">/**
695
 * Hide/unhide a layer. Called by Context when the hidden attribute changes.
696
 * <span class="attrib">@param</span> objRef Pointer to widget object.
697
 * <span class="attrib">@param</span> layerId Id of the layer to hide/unhide.
698
 */</span>
699
MapPaneOL.<span class="reserved">prototype</span>.hidden = <span class="reserved">function</span>(objRef, layerId) {
700
  var vis=objRef.model.getHidden(layerId);
701
  <span class="reserved">if</span>(vis==<span class="literal">"1"</span>){ var hidden=false; }
702
  <span class="reserved">else</span> {var hidden=true; }
703
  var  tmpLayer=objRef.getLayer(objRef,layerId)
704
  <span class="reserved">if</span>(tmpLayer)tmpLayer.setVisibility(hidden);
705
}
706

    
707
<span class="comment">/**
708
  * Returns OL layer node from LayerMgr
709
  * <span class="attrib">@param</span> layerId The layer Id (or layerName)
710
  */</span>
711
MapPaneOL.<span class="reserved">prototype</span>.getLayer = <span class="reserved">function</span>(objRef,layerId) {
712
<span class="comment">
713
  // If layer cannot be found then layerId might actually be layerName</span>
714
<span class="comment">  // We then try to fetch the <span class="attrib">@id</span> of the layer from the model</span>
715
  <span class="reserved">if</span> (!objRef.oLlayers[layerId]) {
716
    layerId = objRef.model.getLayerIdByName(layerId) || layerId;
717
  }
718

    
719
  <span class="reserved">if</span>(objRef.oLlayers[layerId] &amp;&amp; objRef.oLlayers[layerId].id) {
720
    <span class="reserved">return</span> objRef.model.map.getLayer(objRef.oLlayers[layerId].id);
721
  } <span class="reserved">else</span> {
722
    <span class="reserved">return</span> false;
723
  }
724
}
725
<span class="comment">
726

    
727
//####################################################</span>
728
<span class="comment">/**
729
 * Removes a layer from the output
730
/**
731
 * Removes a layer from the output
732
 * <span class="attrib">@param</span> objRef Pointer to this object.
733
 * <span class="attrib">@param</span> layerId the WMS name for the layer to be removed
734
 */</span>
735
MapPaneOL.<span class="reserved">prototype</span>.deleteLayer = <span class="reserved">function</span>(objRef, layerId) {
736
  <span class="reserved">if</span>(objRef.oLlayers[layerId])objRef.model.map.removeLayer(objRef.oLlayers[layerId]);
737
}
738
<span class="comment">/**
739
 * Removes all layers from the output
740
 * <span class="attrib">@param</span> objRef Pointer to this object.
741
 * <span class="attrib">@param</span> objRef Pointer to this object.
742
 */</span>
743
MapPaneOL.<span class="reserved">prototype</span>.deleteAllLayers = <span class="reserved">function</span>(objRef) {
744
  <span class="reserved">for</span> (var i in objRef.oLlayers) {
745
    var layer = objRef.oLlayers[i];
746
    layer.destroy();
747
  }
748
  objRef.oLlayers = {};
749
}
750
<span class="comment">
751
//#############################################TDO</span>
752
<span class="comment">/**
753
 * Moves a layer up in the stack of map layers
754
 * <span class="attrib">@param</span> objRef Pointer to this object.
755
 * <span class="attrib">@param</span> layerId the WMS name for the layer to be removed
756
 */</span>
757
MapPaneOL.<span class="reserved">prototype</span>.moveLayerUp = <span class="reserved">function</span>(objRef, layerId) {
758
  var map=objRef.model.map;
759
  map.raiseLayer(map.getLayer(objRef.oLlayers[layerId].id), 1);
760
}
761

    
762
<span class="comment">/**
763
 * Moves a layer up in the stack of map layers
764
 * <span class="attrib">@param</span> objRef Pointer to this object.
765
 * <span class="attrib">@param</span> layerId the WMS name for the layer to be removed
766
 */</span>
767
MapPaneOL.<span class="reserved">prototype</span>.moveLayerDown = <span class="reserved">function</span>(objRef, layerId) {
768
  objRef.model.map.raiseLayer(objRef.getLayer(objRef,layerId), -1);
769
}
770
<span class="comment">//###############################################</span>
771
<span class="comment">/**
772
   * Called when the context's opacity attribute changes.
773
/**
774
   * Called when the context's opacity attribute changes.
775
   * <span class="attrib">@param</span> objRef This object.
776
   * <span class="attrib">@param</span> layerId  The id of the layer that was toggled.
777
   */</span>
778
MapPaneOL.<span class="reserved">prototype</span>.setOpacity=<span class="reserved">function</span>(objRef, layerId){
779
  var _opacity=<span class="literal">"1"</span>;
780
  _opacity=objRef.model.getOpacity(layerId);
781
  objRef.getLayer(objRef,layerId).setOpacity(_opacity);
782
}
783
<span class="comment">/**
784
 * Adds a layer into the output
785
   * <span class="attrib">@param</span> objRef This object.
786
   * <span class="attrib">@param</span> layerNode  The node of the layer
787
 */</span>
788
MapPaneOL.<span class="reserved">prototype</span>.addLayer = <span class="reserved">function</span>(objRef, layerNode) {
789
<span class="comment">  // OpenLayers doesn't contain information about projection, so if the</span>
790
<span class="comment">  // baseLayer projection is not standard lat/long, it needs to know</span>
791
<span class="comment">  // maxExtent and maxResolution to calculate the zoomLevels.</span>
792
  var layer = layerNode;
793
<span class="comment">
794
  // Test service of the layer</span>
795
  var service=layer.selectSingleNode(<span class="literal">"wmc:Server/@service"</span>);service=(service)?service.nodeValue:<span class="literal">""</span>;
796
<span class="comment">
797
  // Test title of the layer</span>
798
  var title=Mapbuilder.getProperty(layer, <span class="literal">"wmc:Title"</span>, <span class="literal">""</span>);
799
<span class="comment">
800
  // Get the name of the layer</span>
801
  layerName = Mapbuilder.getProperty(layer, <span class="literal">"wmc:Name"</span>, <span class="literal">""</span>);
802
<span class="comment">
803
  // Get the layerId. Fallback to layerName if non-existent</span>
804
  var layerId;
805
  <span class="reserved">if</span> (layer.selectSingleNode(<span class="literal">"@id"</span>) &amp;&amp; layer.selectSingleNode(<span class="literal">"@id"</span>).nodeValue) {
806
    layerId = layer.selectSingleNode(<span class="literal">"@id"</span>).nodeValue;
807
  } <span class="reserved">else</span> {
808
    layerId = layerName;
809
  }
810

    
811
  <span class="reserved">if</span> (objRef.context==<span class="literal">"OWS"</span>){
812
    var href=Mapbuilder.getProperty(layer, <span class="literal">"wmc:Server/wmc:OnlineResource/@xlink:href"</span>, <span class="literal">""</span>);
813
  }
814
  <span class="reserved">else</span> {
815
     <span class="reserved">if</span>(_SARISSA_IS_SAFARI){
816
     var nodehref=layer.selectSingleNode(<span class="literal">"wmc:Server/wmc:OnlineResource"</span>);
817
     var href=nodehref.attributes[1].nodeValue;
818
     }
819
   <span class="reserved">else</span>{
820
     <span class="reserved">if</span>(_SARISSA_IS_OPERA){
821
       var href=layer.selectSingleNode(<span class="literal">"wmc:Server/wmc:OnlineResource"</span>).getAttributeNS (<span class="literal">"http://www.w3.org/1999/xlink"</span>,<span class="literal">"href"</span>);// <span class="reserved">for</span> opera
822
     }<span class="reserved">else</span>{
823
       var href=layer.selectSingleNode(<span class="literal">"wmc:Server/wmc:OnlineResource"</span>).getAttribute(<span class="literal">"xlink:href"</span>);
824
     }
825
    }
826
  }
827
<span class="comment">
828
  // Test format of the layer</span>
829
  var format=layer.selectSingleNode(<span class="literal">"wmc:FormatList/wmc:Format[@current='1']"</span>);
830
  <span class="reserved">if</span> (!format) {
831
    format = layer.selectSingleNode(<span class="literal">"wmc:FormatList/wmc:Format"</span>);
832
  }
833
  format = format ? getNodeValue(format) : <span class="literal">"image/gif"</span>;
834
<span class="comment">
835
  // Test visibility of the layer</span>
836
  var vis=layer.selectSingleNode(<span class="literal">"@hidden"</span>);
837
  <span class="reserved">if</span> (vis) {
838
    <span class="reserved">if</span>(vis.nodeValue==<span class="literal">"1"</span>)
839
      vis=false;
840
    <span class="reserved">else</span>
841
      vis=true;
842
  }
843
<span class="comment">  // Test if layer is queryable</span>
844
  var query=layer.selectSingleNode(<span class="literal">"@queryable"</span>);
845
  <span class="reserved">if</span> (query){
846
    <span class="reserved">if</span>(query.nodeValue==<span class="literal">"1"</span>)
847
      query=true;
848
    <span class="reserved">else</span>
849
      query=false;
850
  }
851
<span class="comment">
852
  // Test if opacity is specified</span>
853
  var opacity=layer.selectSingleNode(<span class="literal">"@opacity"</span>);
854
  <span class="reserved">if</span> (opacity)
855
    opacity=opacity.nodeValue;
856
  <span class="reserved">else</span>
857
    opacity=false;
858
<span class="comment">  
859
  // Get current style node of the layer</span>
860
  var currentStyle = layer.selectSingleNode(<span class="literal">'wmc:StyleList/wmc:Style[@current=1]'</span>);
861
<span class="comment">
862
  // will be true for IE6, false for later versions of IE</span>
863
  objRef.IE6 = false <span class="comment">/*<span class="attrib">@cc_on</span> || <span class="attrib">@_jscript_version</span> &lt; 5.7 @*/</span>;
864
<span class="comment">  
865
  //default option value for a layer</span>
866
  var layerOptions = {
867
          visibility: vis,
868
          projection: objRef.model.map.baseLayer.projection,
869
          queryable: query,
870
          maxExtent: objRef.model.map.baseLayer.maxExtent,
871
          maxResolution: objRef.model.map.baseLayer.maxResolution,  //<span class="literal">"auto"</span> <span class="reserved">if</span> not defined in the context
872
          minResolution: objRef.model.map.baseLayer.minResolution,  //<span class="literal">"auto"</span> <span class="reserved">if</span> not defined in the context
873
          alpha: format.indexOf(<span class="literal">"png"</span>) != -1 ? objRef.IE6 : false,         //option <span class="reserved">for</span> png transparency with ie6
874
          isBaseLayer: false,
875
          displayOutsideMaxExtent: objRef.displayOutsideMaxExtent
876
     };
877
     
878
  switch(service){
879
<span class="comment">    // WMS Layer (Untiled)</span>
880
    case <span class="literal">"OGC"</span>:
881
    case <span class="literal">"WMS"</span>:
882
    case <span class="literal">"wms"</span>:
883
    case <span class="literal">"OGC:WMS"</span>:
884
      <span class="reserved">if</span>(!objRef.model.map.baseLayer){
885
        layerOptions.isBaseLayer=true;
886
      }
887
      <span class="reserved">else</span> {
888
<span class="comment">        //TBD what if we have layers with different projections in the context?</span>
889
        layerOptions.reproject=objRef.imageReproject;
890
        layerOptions.isBaseLayer=false;
891
      }
892

    
893
      layerOptions.ratio = objRef.imageBuffer;
894
      layerOptions.singleTile = objRef.singleTile;
895
      <span class="reserved">if</span> (objRef.singleTile == true) {
896
        layerOptions.transitionEffect = objRef.transitionEffect;
897
      }
898

    
899
      var params = new Array();
900
      params = sld2UrlParam(currentStyle);
901
      <span class="reserved">if</span> (objRef.model.timestampList &amp;&amp; objRef.model.timestampList.getAttribute(<span class="literal">"layerId"</span>) == layerId) { 
902
        var ts = objRef.model.timestampList.childNodes[0];
903

    
904
        objRef.oLlayers[layerId]= new OpenLayers.Layer.WMS(title,href,{
905
            layers: layerName,
906
<span class="comment">            // "TRUE" in upper case else the context doc boston.xml</span>
907
<span class="comment">            // (i.c. the IONIC WMS/WFS) doesn't work.</span>
908
<span class="comment">            // Note that this is in line with the WMS standard (OGC 01-068r2),</span>
909
<span class="comment">            // section 6.4.1 Parameter Ordering and Case:</span>
910
<span class="comment">            // "Parameter names shall not be case sensitive,</span>
911
<span class="comment">            //  but parameter values shall be case sensitive."</span>
912
            transparent: format.indexOf(<span class="literal">"jpeg"</span>) == -1 ? <span class="literal">"TRUE"</span> : <span class="literal">"FALSE"</span>,
913
            <span class="literal">"TIME"</span>: getNodeValue(ts),	          
914
            format: format,
915
            sld:params.sld,
916
            sld_body:params.sld_body,
917
            styles:params.styles
918
          },
919
          layerOptions
920
        );      
921
<span class="comment">        // Turn on timestamp listenet</span>
922
          <span class="reserved">this</span>.model.addListener(<span class="literal">"timestamp"</span>,<span class="reserved">this</span>.timestampListener,<span class="reserved">this</span>);	      
923
      }
924
      <span class="reserved">else</span> {
925
        objRef.oLlayers[layerId]= new OpenLayers.Layer.WMS(title,href,{
926
            layers: layerName,
927
<span class="comment">            // "TRUE" in upper case else the context doc boston.xml</span>
928
<span class="comment">            // (i.c. the IONIC WMS/WFS) doesn't work.</span>
929
<span class="comment">            // Note that this is in line with the WMS standard (OGC 01-068r2),</span>
930
<span class="comment">            // section 6.4.1 Parameter Ordering and Case:</span>
931
<span class="comment">            // "Parameter names shall not be case sensitive,</span>
932
<span class="comment">            //  but parameter values shall be case sensitive."</span>
933
            transparent: format.indexOf(<span class="literal">"jpeg"</span>) == -1 ? <span class="literal">"TRUE"</span> : <span class="literal">"FALSE"</span>,
934
            format: format,
935
            sld:params.sld,
936
            sld_body:params.sld_body,
937
            styles:params.styles
938
          },
939
          layerOptions
940
        );
941
      }
942
    break;
943
<span class="comment">
944
    // WMS-C Layer (Tiled)</span>
945
    case <span class="literal">"WMS-C"</span>:
946
    case <span class="literal">"OGC:WMS-C"</span>:
947
      <span class="reserved">if</span>(!objRef.model.map.baseLayer){
948
        layerOptions.isBaseLayer=true;
949
      }
950
      <span class="reserved">else</span> {
951
<span class="comment">        //TBD what if we have layers with different projections in the context?</span>
952
        layerOptions.reproject=objRef.imageReproject;
953
        layerOptions.isBaseLayer=false;
954
      }
955

    
956
      layerOptions.gutter = objRef.tileGutter;
957
      layerOptions.buffer = objRef.tileBuffer;
958
      layerOptions.tileSize = new OpenLayers.Size(objRef.tileSize, objRef.tileSize);
959
      
960
      var params = new Array();
961
      params = sld2UrlParam(currentStyle);
962
      objRef.oLlayers[layerId]= new OpenLayers.Layer.WMS(title,href,{
963
          layers: layerName,
964
          transparent: format.indexOf(<span class="literal">"jpeg"</span>) == -1 ? <span class="literal">"TRUE"</span> : <span class="literal">"FALSE"</span>,
965
          format: format,
966
          sld:params.sld,
967
          sld_body:params.sld_body,
968
          styles:params.styles
969
        },
970
        layerOptions
971
      );
972
      objRef.model.map.fractionalZoom = false;
973
    break;
974
<span class="comment">
975
    // WFS Layer</span>
976
    case <span class="literal">"WFS"</span>:
977
    case <span class="literal">"wfs"</span>:
978
    case <span class="literal">"OGC:WFS"</span>:
979
      style = sld2OlStyle(currentStyle);
980
      <span class="reserved">if</span>(style){
981
        layerOptions.styleMap=new OpenLayers.StyleMap(style);
982
      }
983
      <span class="reserved">else</span>{
984
        layerOptions.style=objRef.getWebSafeStyle(objRef, 2*i+1);
985
      }
986
      layerOptions.featureClass=OpenLayers.Feature.WFS;
987

    
988
      objRef.oLlayers[layerId]= new OpenLayers.Layer.WFS(
989
        title,
990
        href,{
991
          typename: layerId,
992
          maxfeatures: 1000},
993
          layerOptions
994
        );
995
    break;
996
<span class="comment">
997
    // GML Layer</span>
998
    case <span class="literal">"gml"</span>:
999
    case <span class="literal">"OGC:GML"</span>:
1000
      style = sld2OlStyle(currentStyle);
1001
      <span class="reserved">if</span>(style){
1002
        layerOptions.styleMap=new OpenLayers.StyleMap(style);
1003
      }
1004
      <span class="reserved">else</span>{
1005
        layerOptions.style=objRef.getWebSafeStyle(objRef, 2*i+1);
1006
      }
1007
      objRef.oLlayers[layerId] = new OpenLayers.Layer.GML(title,href,layerOptions);
1008

    
1009
    break;
1010
<span class="comment">
1011
     // KML Layer</span>
1012
    case <span class="literal">"KML"</span>:
1013
    case <span class="literal">"kml"</span>:
1014
      objRef.oLlayers[layerId]= new OpenLayers.Layer.GML(
1015
        title,
1016
        href,{
1017
          format: OpenLayers.Format.KML
1018
          }
1019
        );
1020
    break;
1021
<span class="comment">    
1022
  // Currently the following layertypes are only supported in a OwsContext doc as a BaseLayer</span>
1023
<span class="comment">  // for more information see http://docs.codehaus.org/display/MAP/Using+Google-layers</span>
1024
   <span class="comment">/* case "GMAP":
1025
    case "Google":
1026
      //the empty baseLayer has to be destroyed when you want to use google
1027
      objRef.model.map.baseLayer.destroy();
1028
      layerOptions.maxExtent=new OpenLayers.Bounds("-20037508", "-20037508", "20037508", "20037508.34");
1029
       objRef.oLlayers[layerId] = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_HYBRID_MAP, maxZoomLevel:18, sphericalMercator: true }, layerOptions );
1030
    break;
1031

    
1032
    case "YMAP":
1033
    case "Yahoo":
1034
      // &lt;script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&amp;appid=euzuro-openlayers"&gt;&lt;/script&gt;
1035
      layerOptions.isBaseLayer=true;
1036
      objRef.oLlayers[layerId] = new OpenLayers.Layer.Yahoo( "Yahoo");
1037
    break;
1038

    
1039
    case "VE":
1040
    case "Microsoft":
1041
      //&lt;script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'&gt;&lt;/script&gt;
1042
      layerOptions.isBaseLayer=true;
1043
      objRef.oLlayers[layerId] = new OpenLayers.Layer.VirtualEarth( "VE",{minZoomLevel: 0, maxZoomLevel: 18,type: VEMapStyle.Hybrid});
1044
    break;
1045

    
1046
    case "MultiMap":
1047
      //&lt;script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"&gt;&lt;/script&gt;
1048
      layerOptions.isBaseLayer=true;
1049
      objRef.oLlayers[layerId] = new OpenLayers.Layer.MultiMap( "MultiMap");
1050
    break;*/</span>
1051
    default:
1052
      alert(mbGetMessage(<span class="literal">"layerTypeNotSupported"</span>, service));
1053
  }
1054
  <span class="reserved">if</span>(opacity &amp;&amp; objRef.oLlayers[layerId]){
1055
    objRef.oLlayers[layerId].setOpacity(opacity);
1056
  }
1057
  
1058
  objRef.oLlayers[layerId].events.register(<span class="literal">'loadstart'</span>, objRef, objRef.increaseLoadingLayers);
1059
  objRef.oLlayers[layerId].events.register(<span class="literal">'loadend'</span>, objRef, objRef.decreaseLoadingLayers);
1060
<span class="comment">  
1061
  // Here the OL layer gets added to the OL map</span>
1062
  objRef.model.map.addLayer(objRef.oLlayers[layerId]);
1063
}
1064

    
1065
<span class="comment">/**
1066
 * gets an OpenLayers vector style with web safe colors.
1067
 * <span class="attrib">@param</span> objRef reference to this object
1068
 * <span class="attrib">@param</span> colorNumber number of a color from which to generate websafe color
1069
 * <span class="attrib">@return</span> {OpenLayers.Style} style for OpenLayers vector rendering
1070
 */</span>
1071
MapPaneOL.<span class="reserved">prototype</span>.getWebSafeStyle = <span class="reserved">function</span>(objRef, colorNumber) {
1072
  colors=new Array(<span class="literal">"00"</span>,<span class="literal">"33"</span>,<span class="literal">"66"</span>,<span class="literal">"99"</span>,<span class="literal">"CC"</span>,<span class="literal">"FF"</span>);
1073
  colorNumber=(colorNumber)?colorNumber:0;
1074
  colorNumber=(colorNumber&lt;0)?0:colorNumber;
1075
  colorNumber=(colorNumber&gt;215)?215:colorNumber;
1076
  i=parseInt(colorNumber/36);
1077
  j=parseInt((colorNumber-i*36)/6);
1078
  k=parseInt((colorNumber-i*36-j*6));
1079
  var color=<span class="literal">"#"</span>+colors[i]+colors[j]+colors[k];
1080
  var defaultStyle = {
1081
            fillColor: <span class="literal">"#808080"</span>,
1082
            fillOpacity: 1,
1083
            strokeColor: <span class="literal">"#000000"</span>,
1084
            strokeOpacity: 1,
1085
            strokeWidth: 1,
1086
            pointRadius: 6};
1087
  var style=OpenLayers.Util.extend(defaultStyle,OpenLayers.Feature.Vector.style[<span class="literal">"default"</span>]);
1088
  style.fillColor = color;
1089
  style.strokeColor = color;
1090
  style.map = objRef.model.map;
1091
  <span class="reserved">return</span> style;
1092
}
1093

    
1094
<span class="comment">/**
1095
   * Called for refreshing one layer.
1096
   * <span class="attrib">@param</span> objRef This object.
1097
   * <span class="attrib">@param</span> layerId  The id of the layer that was toggled.
1098
   */</span>
1099
MapPaneOL.<span class="reserved">prototype</span>.refreshLayer = <span class="reserved">function</span>(objRef, layerId , newParams){
1100
  newParams[<span class="literal">'version'</span>] = Math.random(); //necessary <span class="reserved">for</span> see change in certain case
1101
  objRef.getLayer(objRef,layerId).mergeNewParams(newParams);
1102
}
1103
  
1104
  <span class="comment">/**
1105
   * Called when the map timestamp is changed so set the layer visiblity.
1106
   * <span class="attrib">@param</span> objRef This object.
1107
   * <span class="attrib">@param</span> timestampIndex  The array index for the layer to be displayed. 
1108
   */</span>
1109
MapPaneOL.<span class="reserved">prototype</span>.timestampListener=<span class="reserved">function</span>(objRef, timestampIndex){
1110
  <span class="reserved">if</span> (window.movieLoop.frameIsLoading == true) {
1111
    <span class="reserved">return</span>;
1112
  }
1113
  var layerId = objRef.model.timestampList.getAttribute(<span class="literal">"layerId"</span>);
1114
  var ts = objRef.model.timestampList.childNodes[timestampIndex];
1115

    
1116
  <span class="reserved">if</span> (layerId &amp;&amp; ts) {				
1117
    var curLayer = objRef.oLlayers[layerId]; //TBD: please check <span class="reserved">if</span> <span class="reserved">this</span> still works now we<span class="literal">'ve moved to layerId
1118
    if (!curLayer.grid) {
1119
      return;
1120
    }
1121
    div = curLayer.grid[0][0].imgDiv;
1122
    // Perform URL substitution via regexps
1123
    var oldImageUrl = div.src || div.firstChild.src;
1124
    var newImageUrl = oldImageUrl.replace(/TIME\=.*?\&amp;/,'</span>TIME=<span class="literal">' + getNodeValue(ts) + '</span>&amp;<span class="literal">');
1125
    if (oldImageUrl == newImageUrl) {
1126
      return;
1127
    }
1128

    
1129
    function imageLoaded() {
1130
      window.movieLoop.frameIsLoading = false;
1131
      if(element.removeEventListener) { // Standard
1132
        element.removeEventListener("load", imageLoaded, false);
1133
      } else if(element.detachEvent) { // IE
1134
        element.detachEvent('</span>onload<span class="literal">', imageLoaded);
1135
      }
1136
    }
1137

    
1138
    window.movieLoop.frameIsLoading = true;
1139
    var element = div.nodeName.toUpperCase() == "IMG" ? div : div.firstChild;
1140
    if(element.addEventListener) { // Standard
1141
      element.addEventListener("load", imageLoaded, false);
1142
    } else if(element.attachEvent) { // IE
1143
      element.attachEvent('</span>onload', imageLoaded);
1144
    }
1145
    <span class="reserved">if</span> (objRef.IE6) {
1146
      OpenLayers.Util.modifyAlphaImageDiv(div,
1147
            null, null, null, newImageUrl);
1148
    } <span class="reserved">else</span> {
1149
      element.src = newImageUrl;
1150
    }
1151
  }
1152
      
1153
}
1154
</pre>
1155
	<hr>
1156

    
1157

    
1158

    
1159
<!-- ========== START OF NAVBAR ========== -->
1160
<a name="navbar_top"><!-- --></a>
1161
<table border="0" width="100%" cellpadding="1" cellspacing="0">
1162
<tr>
1163
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
1164
<a name="navbar_top_firstrow"><!-- --></a>
1165
<table border="0" cellpadding="0" cellspacing="3">
1166
  <tr align="center" valign="top">
1167
  
1168
  
1169
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
1170
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
1171
  
1172

    
1173
  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
1174
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
1175
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
1176
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
1177
  </tr>
1178
</table>
1179
</td>
1180
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
1181
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
1182
</td>
1183
</tr>
1184

    
1185
<tr>
1186
<td bgcolor="white" class="NavBarCell2"><font size="-2">
1187
&nbsp;PREV&nbsp;
1188
&nbsp;NEXT</font></td>
1189
<td bgcolor="white" class="NavBarCell2"><font size="-2">
1190
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
1191
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
1192
&nbsp;&nbsp;
1193
<script>
1194
  <!--
1195
  if(window==top) {
1196
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
1197
  }
1198
  //-->
1199
</script>
1200
<noscript>
1201
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
1202
</noscript>
1203
</font></td>
1204
</tr>
1205
</table>
1206
<!-- =========== END OF NAVBAR =========== -->
1207

    
1208
<hr>
1209
<font size="-1">
1210

    
1211
</font>
1212
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Sun Apr 27 20:30:54 2008</div>
1213
</body>
1214
</html>
(260-260/316)