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="Graticule.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>Graticule.js</h2>
72
	
73
</center>
74

    
75
	
76

    
77

    
78
<h4>Summary</h4>
79
<p>
80
	
81
		No overview generated for 'Graticule.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="Graticule.html">Graticule</a></b></td>
99
    <td>&nbsp;</td>
100
    </tr>
101
    
102
    </table>
103
    <hr/> 
104

    
105

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

    
108
<!-- ========== END METHOD SUMMARY =========== -->
109

    
110

    
111
        <pre class="sourceview"><span class="comment">/*
112
Author:       Olivier Terral olivier.terralATgeomatys.fr
113
License:      LGPL as per: http://www.gnu.org/copyleft/lesser.html
114

    
115
$Id: Graticule.js 3879 2008-02-27 14:20:29Z gjvoosten $
116
*/</span>
117
<span class="comment">// Ensure this object's dependancies are loaded.</span>
118
mapbuilder.loadScript(baseDir+<span class="literal">"/widget/ButtonBase.js"</span>);
119

    
120

    
121
<span class="comment">/**
122
 * Render a Graticule.
123
 * <span class="attrib">@constructor</span>
124
 * <span class="attrib">@base</span> ButtonBase
125
 * <span class="attrib">@param</span> widgetNode  The widget's XML object node from the configuration document.
126
 * <span class="attrib">@param</span> model       The model object that this widget belongs to.
127
 */</span>
128
<span class="reserved">function</span> Graticule(widgetNode, model) {
129

    
130
	ButtonBase.apply(<span class="reserved">this</span>, new Array(widgetNode, model));
131

    
132
	<span class="reserved">this</span>.display=false;
133
	<span class="reserved">this</span>.color=<span class="reserved">this</span>.getProperty(<span class="literal">"mb:color"</span>);
134
	
135
	<span class="comment">/**
136
   * Interactive ZoomOut control.
137
   * <span class="attrib">@param</span> objRef reference to this object.
138
   * <span class="attrib">@return</span> {OpenLayers.Control} class of the OL control.
139
   */</span>
140
  <span class="reserved">this</span>.createControl = <span class="reserved">function</span>(objRef) {
141
    var Control = OpenLayers.Class( OpenLayers.Control, {
142
      CLASS_NAME: <span class="literal">'mbControl.Graticule'</span>,
143
      type: OpenLayers.Control.TYPE_TOGGLE,
144
	  destroy : <span class="reserved">function</span>() {
145
	    OpenLayers.Control.<span class="reserved">prototype</span>.destroy.apply(<span class="reserved">this</span>, arguments);
146
	    <span class="reserved">if</span> (<span class="reserved">this</span>.divs) {
147
	      <span class="reserved">for</span>(i = <span class="reserved">this</span>.divs.length; i &gt; 0; --i) {
148
		<span class="reserved">this</span>.divs[i] = null;
149
	      }
150
	    }
151
	    <span class="reserved">this</span>.div = null;
152
	    <span class="reserved">this</span>.mapContainer = null;
153
	  },
154
<span class="comment">	    
155
////////////////////////////ancien/////////////////////	</span>
156
<span class="comment">/**
157
   * Remove divs
158
   * <span class="attrib">@param</span> objRef Pointer to this object.
159
   */</span>
160
	removeGraticules : <span class="reserved">function</span>() {
161
	
162
	  try{
163
			  var i = 0;
164
			  var div = <span class="reserved">this</span>.mapContainer;
165
		
166
		      <span class="reserved">if</span> (<span class="reserved">this</span>.divs) {
167
		  	<span class="reserved">for</span>(i=0; i&lt; <span class="reserved">this</span>.divs.length; i++)
168
		  	{
169
				div.removeChild(<span class="reserved">this</span>.divs[i]);
170
			}
171
		      }
172
	  }
173
	  catch(e){
174
	  }
175
	
176
	},
177

    
178
	<span class="comment">/**
179
   * Get bbox of MapPane with the right projection
180
   * Return an object
181
   * <span class="attrib">@param</span> this Pointer to this object.
182
   */</span>
183
	getBbox : <span class="reserved">function</span>() {
184
	
185
			var bbox=new Object();
186
			bbox.ll=new Object();
187
			bbox.ur=new Object();
188
<span class="comment">			///CSCS</span>
189
    		var ll=new OpenLayers.Geometry.Point(<span class="reserved">this</span>.bbox[0], <span class="reserved">this</span>.bbox[1]);
190
    		var ur=new OpenLayers.Geometry.Point(<span class="reserved">this</span>.bbox[2], <span class="reserved">this</span>.bbox[3]);
191
    		var wgs84 = new OpenLayers.Projection(<span class="literal">"EPSG:4326"</span>);
192
    		
193
    		ll.transform(<span class="reserved">this</span>.proj, wgs84);
194
    		ur.transform(<span class="reserved">this</span>.proj, wgs84);
195
		
196
			
197
			bbox.ll.lon=ll.x;		//minx
198
			bbox.ll.lat=ll.y;		//miny
199
			bbox.ur.lon=ur.x;		//maxx
200
			bbox.ur.lat=ur.y;		//maxy
201
		
202
			<span class="reserved">return</span> bbox;
203
		
204
	},
205

    
206
	<span class="comment">/**
207
   * Calculate rounded graticule interval for supplied lat/lon span
208
   * 
209
   * <span class="attrib">@param</span> dDeg difference in degrees.
210
   */</span>
211
<span class="comment">	//</span>
212
<span class="comment">	//return is in minutes</span>
213
	gridIntervalMins : <span class="reserved">function</span>(dDeg) {  
214
	
215
	  var dDeg = dDeg/10;				//want around 10 lines in the graticule
216
	  dDeg *= 6000;						//to minutes*100
217
	  dDeg = Math.ceil(dDeg)/100;		//minutes and hundredths of mins
218
	
219
	  <span class="reserved">if</span>(dDeg &lt;= 0.06)
220
		dDeg = 0.06;//0.001 degrees
221
	  <span class="reserved">else</span> <span class="reserved">if</span>(dDeg &lt;= 0.12)
222
		dDeg = 0.12;//0.002 degrees
223
	  <span class="reserved">else</span> <span class="reserved">if</span>(dDeg &lt;= 0.3)
224
		dDeg = 0.3;//0.005 degrees
225
	  <span class="reserved">else</span> <span class="reserved">if</span>(dDeg &lt;= 0.6)
226
		dDeg = 0.6;//0.01 degrees
227
	  <span class="reserved">else</span> <span class="reserved">if</span> (dDeg &lt;=  1.2)
228
		dDeg = 1.2;//0.02 degrees
229
	  <span class="reserved">else</span> <span class="reserved">if</span>(dDeg &lt;= 3)
230
		dDeg = 3;//0.05 degrees
231
	  <span class="reserved">else</span> <span class="reserved">if</span>(dDeg &lt;= 6)
232
		dDeg = 6;//0.1 degrees
233
	  <span class="reserved">else</span> <span class="reserved">if</span> (dDeg &lt;=  12)
234
		dDeg = 12;//0.2 degrees
235
	  <span class="reserved">else</span> <span class="reserved">if</span> (dDeg &lt;=  30)
236
		dDeg = 30;//0.5
237
	  <span class="reserved">else</span> <span class="reserved">if</span> (dDeg &lt;=  60)
238
		dDeg = 30;//1
239
	  <span class="reserved">else</span> <span class="reserved">if</span> (dDeg &lt;=  (60*2))
240
		dDeg = 60*2;
241
	  <span class="reserved">else</span> <span class="reserved">if</span> (dDeg &lt;=  (60*5))
242
		dDeg = 60*5;
243
	  <span class="reserved">else</span> <span class="reserved">if</span> (dDeg &lt;=  (60*10))
244
		dDeg = 60*10;
245
	  <span class="reserved">else</span> <span class="reserved">if</span> (dDeg &lt;=  (60*20))
246
		dDeg = 60*20;
247
	  <span class="reserved">else</span> <span class="reserved">if</span> (dDeg &lt;=  (60*30))
248
		dDeg = 60*30;
249
	  <span class="reserved">else</span>
250
		dDeg = 60*45;
251
	  
252
		
253
	  <span class="reserved">return</span> dDeg;
254
	
255
},
256

    
257

    
258
	
259
	<span class="comment">/* Calculate grid label precision from grid interval in degrees
260
	*
261
	*<span class="attrib">@param</span> dDeg difference in degrees.
262
	*/</span>
263
	gridPrecision : <span class="reserved">function</span>(dDeg) {
264
		<span class="reserved">if</span>(dDeg &lt; 0.01)
265
			<span class="reserved">return</span> 3;
266
		<span class="reserved">else</span> <span class="reserved">if</span>(dDeg &lt; 0.1)
267
			<span class="reserved">return</span> 2;
268
		<span class="reserved">else</span> <span class="reserved">if</span>(dDeg &lt; 1)
269
			<span class="reserved">return</span> 1;
270
		<span class="reserved">else</span> <span class="reserved">return</span> 0;
271
	},
272

    
273
	<span class="comment">/* Draw graticules
274
	*
275
	*<span class="attrib">@param</span> this pointer to this object.
276
	*/</span>
277
	addGraticules : <span class="reserved">function</span>(){
278
<span class="comment">
279
		//Delete old graticule</span>
280
		<span class="reserved">this</span>.removeGraticules();
281
		
282
		var bbox=<span class="reserved">this</span>.getBbox();
283
		
284
		var l=bbox.ll.lon; //////ll:lower left coordinates 
285
		var b=bbox.ll.lat;		//ll:lower left ,ll.long : latitude(y) de coin en bas a gauche
286
		var r=bbox.ur.lon;			//ur:upper right ,ur.long : longitude de coin en haut a droite
287
		var t=bbox.ur.lat;		
288
<span class="comment">		
289
		 //test if coords are valid</span>
290
		  <span class="reserved">if</span> (b &lt; -90.0)
291
			b = -90.0;
292
		  <span class="reserved">if</span>(t &gt; 90.0)
293
			t = 90.0;
294
		  <span class="reserved">if</span>(l &lt; -180.0)
295
		    l = -180.0;  
296
		  <span class="reserved">if</span>(r &gt; 180.0)
297
		    r = 180.0;
298
		    
299
		  <span class="reserved">if</span>(l == r){
300
			l = -180.0;
301
			r = 180.0;
302
		  }
303
		
304
		  <span class="reserved">if</span>(t == b){
305
			b = -90.0;
306
			t = 90.0;
307
		  }
308
<span class="comment">		 
309
		  
310
		  
311
		  //grid interval in minutes    </span>
312
		  var dLat = <span class="reserved">this</span>.gridIntervalMins(t-b);
313
		  var dLng; 
314
		  <span class="reserved">if</span>(r&gt;l)
315
			dLng = <span class="reserved">this</span>.gridIntervalMins(r-l);
316
		  <span class="reserved">else</span>
317
		    dLng = <span class="reserved">this</span>.gridIntervalMins((180-l)+(r+180));
318
<span class="comment">		
319
		  //round iteration limits to the computed grid interval</span>
320
		  l = Math.floor(l*60/dLng)*dLng/60;
321
		  b = Math.floor(b*60/dLat)*dLat/60;
322
		  t = Math.ceil(t*60/dLat)*dLat/60;
323
		  r = Math.ceil(r*60/dLng)*dLng/60;
324
<span class="comment">		  
325
		
326
		
327
		  //Tes if coords are valid</span>
328
		  <span class="reserved">if</span> (b &lt;= -90.0)
329
			b = -90;
330
		  <span class="reserved">if</span>(t &gt;= 90.0)
331
			t = 90;
332
		  <span class="reserved">if</span>(l &lt; -180.0)
333
		    l = -180.0;  
334
		  <span class="reserved">if</span>(r &gt; 180.0)
335
		    r = 180.0;
336
<span class="comment">		    
337
		  //to whole degrees</span>
338
		  dLat /= 60;
339
		  dLng /= 60;
340

    
341
		  <span class="reserved">this</span>.dLat=dLat;
342
		  <span class="reserved">this</span>.dLon=dLng;
343
<span class="comment">		  
344
		  //# digits after DP for labels</span>
345
		  var latDecs = <span class="reserved">this</span>.gridPrecision(dLat);
346
		  var lonDecs = <span class="reserved">this</span>.gridPrecision(dLng);
347
<span class="comment">		 
348
		  //array for divs used for lines and labels</span>
349
		  <span class="reserved">this</span>.divs = new Array();
350
		  var i=0;//count inserted divs
351
<span class="comment">		
352
		  //min and max x and y pixel values for graticule lines</span>
353
		  var pbl = <span class="reserved">this</span>.fromLatLngToDivPixel(b,l);
354
		  var ptr = <span class="reserved">this</span>.fromLatLngToDivPixel(t,r);
355
		
356
		  
357
		  <span class="reserved">this</span>.maxX = ptr.x;
358
		  <span class="reserved">this</span>.maxY = pbl.y;
359
		  <span class="reserved">this</span>.minX = pbl.x;
360
		  <span class="reserved">this</span>.minY = ptr.y;
361
		  var x;//coord <span class="reserved">for</span> label
362
<span class="comment">		  
363
		  //labels on second column to avoid peripheral controls</span>
364
		  var y = <span class="reserved">this</span>.fromLatLngToDivPixel(b+dLat+dLat,l).y + 2;//coord <span class="reserved">for</span> label
365
<span class="comment">		  
366
		  //pane/layer to write on</span>
367
		  var mapDiv = <span class="reserved">this</span>.mapContainer;//<span class="reserved">this</span>.map_.getPane(G_MAP_MARKER_SHADOW_PANE);
368
		  
369
		  var lo = l;
370
		  
371
		  <span class="reserved">if</span>(r&lt;lo)
372
		      r += 360.0;
373
<span class="comment">		
374
		  //vertical lines</span>
375
		  <span class="reserved">while</span>(lo&lt;=r){
376
				
377
				 var p = <span class="reserved">this</span>.fromLatLngToDivPixel(b,lo);
378
<span class="comment">				 //line</span>
379
				 <span class="reserved">this</span>.divs[i] = <span class="reserved">this</span>.createVLine(p.x);
380
				 <span class="reserved">this</span>.divs[i].style.zIndex = <span class="reserved">this</span>.div.style.zIndex;
381
				 mapDiv.insertBefore(<span class="reserved">this</span>.divs[i],null);
382
				 i++;
383
<span class="comment">				  	
384
				 //label	 </span>
385
				 var d = document.createElement(<span class="literal">"DIV"</span>);
386
				 x = p.x + 3;
387
				 
388
				 d.style.position = <span class="literal">"absolute"</span>;
389
		         d.style.left = x.toString() + <span class="literal">"px"</span>;
390
		         d.style.top = y.toString() + <span class="literal">"px"</span>;
391
				 d.style.color = <span class="reserved">this</span>.color;
392
				 d.style.fontFamily=<span class="literal">'Arial'</span>;
393
				 d.style.fontSize=<span class="literal">'x-small'</span>;
394
		         
395
		         <span class="reserved">if</span> (lo==0)
396
		         {
397
		         	d.innerHTML = (Math.abs(lo)).toFixed(lonDecs);
398
		         }
399
			     <span class="reserved">else</span> <span class="reserved">if</span>(lo&lt;0)
400
				{	d.title = mbGetMessage(<span class="literal">"westWgs84"</span>);
401
					d.innerHTML = (Math.abs(lo)).toFixed(lonDecs)+<span class="literal">" W"</span>;
402
				 }
403
				 <span class="reserved">else</span> 
404
				{	d.title = mbGetMessage(<span class="literal">"eastWgs84"</span>);
405
					d.innerHTML = (Math.abs(lo)).toFixed(lonDecs)+<span class="literal">" E"</span>;
406
				 }
407
				 
408
				d.style.zIndex = <span class="reserved">this</span>.div.style.zIndex;
409
				 mapDiv.insertBefore(d,null);
410
				 <span class="reserved">this</span>.divs[i] = d;
411
			
412
				 i++;
413
				 lo += dLng;	
414
				 <span class="reserved">if</span> (lo &gt; 180.0){
415
					r -= 360.0;
416
					lo -= 360.0;
417
					}		 		
418
  	}
419
  
420

    
421

    
422
	var j = 0;
423
<span class="comment">	      
424
	  //labels on second row to avoid controls</span>
425
	  x = <span class="reserved">this</span>.fromLatLngToDivPixel(b,l+dLng+dLng).x + 3;
426
<span class="comment">	  
427
	  //horizontal lines</span>
428
	  <span class="reserved">while</span>(b&lt;=t){
429

    
430
			 var p = <span class="reserved">this</span>.fromLatLngToDivPixel(b,l);
431
<span class="comment">			 
432
			 //line</span>
433
			 <span class="reserved">if</span>(r &lt; l){ //draw lines across the dateline
434
				<span class="reserved">this</span>.divs[i] = <span class="reserved">this</span>.createHLine3(b);
435
				<span class="reserved">this</span>.divs[i].style.zIndex = <span class="reserved">this</span>.div.style.zIndex;
436
				mapDiv.insertBefore(<span class="reserved">this</span>.divs[i],null);
437
				i++;
438
			 }
439
			 <span class="reserved">else</span> <span class="reserved">if</span> (r == l){ //draw lines <span class="reserved">for</span> world scale zooms
440
			
441
				<span class="reserved">this</span>.divs[i] = <span class="reserved">this</span>.createHLine3(b);
442
				<span class="reserved">this</span>.divs[i].style.zIndex = <span class="reserved">this</span>.div.style.zIndex;
443
				mapDiv.insertBefore(<span class="reserved">this</span>.divs[i],null);
444
				i++;
445
			 }
446
			 <span class="reserved">else</span>{
447
			 	
448
				<span class="reserved">this</span>.divs[i] = <span class="reserved">this</span>.createHLine(p.y);
449
				<span class="reserved">this</span>.divs[i].style.zIndex = <span class="reserved">this</span>.div.style.zIndex;
450
				mapDiv.insertBefore(<span class="reserved">this</span>.divs[i],null);
451
				i++;
452
			 }
453
<span class="comment">			 
454
			 
455
			 
456
			 
457
			 //label</span>
458
			 var d = document.createElement(<span class="literal">"DIV"</span>);
459
			 y = p.y + 2;
460
			 d.style.position = <span class="literal">"absolute"</span>;
461
			 d.style.left =x.toString() + <span class="literal">"px"</span>;
462
			 d.style.top = y.toString()+ <span class="literal">"px"</span>;
463
			 d.style.color = <span class="reserved">this</span>.color;
464
			 d.style.fontFamily=<span class="literal">'Arial'</span>;
465
			 d.style.fontSize=<span class="literal">'x-small'</span>;
466
			 
467
			 <span class="reserved">if</span> (b==0)
468
	         {
469
	         	d.innerHTML = (Math.abs(b)).toFixed(lonDecs);
470
	         }
471
			 <span class="reserved">else</span> <span class="reserved">if</span>(b&lt;0)
472
			{	d.title = mbGetMessage(<span class="literal">"southWgs84"</span>);
473
				d.innerHTML = (Math.abs(b)).toFixed(latDecs)+<span class="literal">" S"</span>;
474
			}
475
			 <span class="reserved">else</span> 
476
			{	d.title = mbGetMessage(<span class="literal">"northWgs84"</span>);
477
				d.innerHTML = (Math.abs(b)).toFixed(latDecs)+<span class="literal">" N"</span>;
478
			}
479
			 <span class="reserved">if</span>(j != 2)//dont put two labels in the same place
480
			 {
481
			 	 
482
				 d.style.zIndex = <span class="reserved">this</span>.div.style.zIndex;
483
				 mapDiv.insertBefore(d,null);
484
				 <span class="reserved">this</span>.divs[i] = d;
485
				 i++;
486
			 }
487
			 j++;
488
			 b += dLat;
489
	  }
490
	 
491

    
492
	},
493
	
494
	<span class="comment">/*Transform lat/lon coordinates in pixels coordinates
495
	* Returns an object container pixel coordinates
496
	*<span class="attrib">@param</span> this pointer to this object.
497
	*<span class="attrib">@param</span> lat lon  coordiantes in degrees 
498
	*/</span>
499
	fromLatLngToDivPixel : <span class="reserved">function</span>(lat,lon){
500
<span class="comment">		///CSCS</span>
501
    var pt=new OpenLayers.Geometry.Point(lon, lat);
502
    pt.transform(new OpenLayers.Projection(<span class="literal">"EPSG:4326"</span>),<span class="reserved">this</span>.proj);
503
    var platlon=<span class="reserved">this</span>.map.getPixelFromLonLat(new OpenLayers.LonLat(pt.x,pt.y));
504
		<span class="reserved">return</span> platlon;
505
	},
506
	
507
	<span class="comment">/*Create a vertical line
508
	* Returns a div that is a vertical single pixel line
509
	*<span class="attrib">@param</span> this pointer to this object.
510
	*<span class="attrib">@param</span> x left style property for div element 
511
	*/</span>
512
	
513
	createVLine : <span class="reserved">function</span> (x) {
514

    
515
		var div = document.createElement(<span class="literal">"DIV"</span>);
516
		div.style.position = <span class="literal">"absolute"</span>;
517
		div.style.overflow = <span class="literal">"hidden"</span>;
518
		div.style.backgroundColor = <span class="reserved">this</span>.color;
519
		div.style.left = x + <span class="literal">"px"</span>;
520
		div.style.top = <span class="reserved">this</span>.minY + <span class="literal">"px"</span>;
521
		div.style.width = <span class="literal">"1px"</span>;
522
		div.style.height = (<span class="reserved">this</span>.maxY-<span class="reserved">this</span>.minY) +<span class="literal">"px"</span>;				
523
	    <span class="reserved">return</span> div;
524
	
525
	},
526
 
527
	<span class="comment">/*Create a horizontal line
528
	* Returns a div that is a horizontal single pixel line
529
	*<span class="attrib">@param</span> this pointer to this object.
530
	*<span class="attrib">@param</span> y top style property for div element 
531
	*/</span>  	  
532
	createHLine : <span class="reserved">function</span>(y) {
533

    
534
		var div = document.createElement(<span class="literal">"DIV"</span>);
535
		div.style.position = <span class="literal">"absolute"</span>;
536
		div.style.overflow = <span class="literal">"hidden"</span>;
537
		div.style.backgroundColor = <span class="reserved">this</span>.color;
538
		div.style.left = <span class="reserved">this</span>.minX + <span class="literal">"px"</span>;
539
		div.style.top = y + <span class="literal">"px"</span>;
540
		div.style.width = (<span class="reserved">this</span>.maxX-<span class="reserved">this</span>.minX) + <span class="literal">"px"</span>;
541
		div.style.height = <span class="literal">"1px"</span>;
542
	    <span class="reserved">return</span> div;
543
	
544
	},
545
	<span class="comment">/*Create a horizontal line
546
	* Returns a div that is a horizontal single pixel line, across the dateline  
547
	* we find the start and width of a 180 degree line and draw the same amount
548
	* to its left and right	
549
	*<span class="attrib">@param</span> this pointer to this object.
550
	*<span class="attrib">@param</span> lat latitude of  div element.
551
	*/</span>  
552
		createHLine3 : <span class="reserved">function</span>(lat) {
553
		
554
			var f = <span class="reserved">this</span>.fromLatLngToDivPixel(lat,0);
555
			var t = <span class="reserved">this</span>.fromLatLngToDivPixel(lat,180);		
556
		
557
			var div = document.createElement(<span class="literal">"DIV"</span>);
558
			div.style.position = <span class="literal">"absolute"</span>;
559
			div.style.overflow = <span class="literal">"hidden"</span>;
560
			div.style.backgroundColor = <span class="reserved">this</span>.color;
561
			
562
			var x1 = f.x;
563
			var x2 = t.x;
564
			
565
			<span class="reserved">if</span>(x2 &lt; x1)
566
			{
567
				x2 = f.x;
568
				x1 = t.x;
569
			}
570
			div.style.left = (x1-(x2-x1)) + <span class="literal">"px"</span>;
571
			div.style.top = f.y + <span class="literal">"px"</span>;
572
			div.style.width = ((x2-x1)*2) + <span class="literal">"px"</span>;
573
			div.style.height = <span class="literal">"1px"</span>;
574
			<span class="reserved">return</span> div;
575
			
576
			
577
}  ,
578

    
579
		<span class="comment">/*Initialize Graticule's property 
580
		* 
581
		*<span class="attrib">@param</span> this pointer to this object.
582
		*/</span> 
583
		update : <span class="reserved">function</span> (){
584
		
585
		
586
			<span class="reserved">this</span>.width=parseInt(<span class="reserved">this</span>.objRef.targetModel.getWindowWidth());
587
			<span class="reserved">this</span>.height=parseInt(<span class="reserved">this</span>.objRef.targetModel.getWindowHeight());
588
			
589
			<span class="reserved">this</span>.bbox=<span class="reserved">this</span>.objRef.targetModel.getBoundingBox();
590
			<span class="reserved">this</span>.proj=new OpenLayers.Projection( <span class="reserved">this</span>.objRef.targetModel.getSRS());
591
		
592
			<span class="reserved">if</span> (<span class="reserved">this</span>.bbox[1]&lt;0)
593
				<span class="reserved">if</span>(<span class="reserved">this</span>.bbox[3]&lt;0)
594
					<span class="reserved">this</span>.diffLat=<span class="reserved">this</span>.bbox[1]-<span class="reserved">this</span>.bbox[3];
595
				<span class="reserved">else</span>
596
					<span class="reserved">this</span>.diffLat=<span class="reserved">this</span>.bbox[3]-<span class="reserved">this</span>.bbox[1];
597
			<span class="reserved">else</span>
598
				<span class="reserved">this</span>.diffLat=<span class="reserved">this</span>.bbox[3]+<span class="reserved">this</span>.bbox[1];
599
				
600
			<span class="reserved">if</span> (<span class="reserved">this</span>.bbox[0]&lt;0)
601
				<span class="reserved">if</span>(<span class="reserved">this</span>.bbox[2]&lt;0)		
602
					<span class="reserved">this</span>.diffLon=<span class="reserved">this</span>.bbox[0]-<span class="reserved">this</span>.bbox[2];
603
				<span class="reserved">else</span>
604
					<span class="reserved">this</span>.diffLon=<span class="reserved">this</span>.bbox[2]-<span class="reserved">this</span>.bbox[0];
605
			<span class="reserved">else</span>
606
				<span class="reserved">this</span>.diffLon=<span class="reserved">this</span>.bbox[2]+<span class="reserved">this</span>.bbox[0];
607
		
608
			
609
		  	<span class="reserved">this</span>.addGraticules();
610

    
611
},
612

    
613
		<span class="comment">/*Display graticule when click on button
614
		* 
615
		*<span class="attrib">@param</span> this pointer to this object.
616
		*<span class="attrib">@param</span> selected boolean true if button has been clicked , false if no
617
		*/</span> 
618
		activate: <span class="reserved">function</span>() {
619
		
620
		<span class="reserved">if</span>(OpenLayers.Control.<span class="reserved">prototype</span>.activate.apply(<span class="reserved">this</span>, arguments)){
621
                <span class="reserved">this</span>.panel_div.style.backgroundImage = <span class="literal">"url(\"</span><span class="literal">"+objRef.enabledImage+"</span>\<span class="literal">")"</span>;
622
<span class="comment">    	//this.map.div.style.cursor = objRef.cursor;</span>
623
			<span class="reserved">this</span>.map.events.register(<span class="literal">'moveend'</span>, <span class="reserved">this</span>, <span class="reserved">this</span>.update);
624
		 	<span class="reserved">this</span>.objRef.display=true;
625
		 	<span class="reserved">this</span>.mapContainer = <span class="reserved">this</span>.div;
626
		 	<span class="reserved">this</span>.color=<span class="literal">"black"</span>;
627
			<span class="reserved">this</span>.update();
628
		<span class="reserved">return</span> true;
629
        } <span class="reserved">else</span> {
630
            <span class="reserved">return</span> false;
631
        }
632
        },
633
		deactivate: <span class="reserved">function</span>() {
634
		<span class="reserved">if</span>(OpenLayers.Control.<span class="reserved">prototype</span>.deactivate.apply(<span class="reserved">this</span>, arguments)){
635
		    <span class="reserved">this</span>.panel_div.style.backgroundImage = <span class="literal">"url(\"</span><span class="literal">"+objRef.disabledImage+"</span>\<span class="literal">")"</span>;
636
			<span class="reserved">this</span>.map.events.unregister(<span class="literal">'moveend'</span>, <span class="reserved">this</span>, <span class="reserved">this</span>.update);
637
			<span class="reserved">this</span>.objRef.display=false;
638
			<span class="reserved">this</span>.removeGraticules(); 
639
			objRef.enabled = false;
640
      		objRef.doSelect(objRef, false); 
641
       		<span class="reserved">this</span>.active=false;
642
       		<span class="reserved">return</span> true;
643
        } <span class="reserved">else</span> {
644
            <span class="reserved">return</span> false;
645
        }
646
	}
647
<span class="comment">/////////////////////////////////////////////////////////////</span>
648

    
649
   });
650

    
651
    <span class="reserved">return</span> Control;
652
  }
653
}
654

    
655
</pre>
656
	<hr>
657

    
658

    
659

    
660
<!-- ========== START OF NAVBAR ========== -->
661
<a name="navbar_top"><!-- --></a>
662
<table border="0" width="100%" cellpadding="1" cellspacing="0">
663
<tr>
664
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
665
<a name="navbar_top_firstrow"><!-- --></a>
666
<table border="0" cellpadding="0" cellspacing="3">
667
  <tr align="center" valign="top">
668
  
669
  
670
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
671
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
672
  
673

    
674
  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
675
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
676
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
677
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
678
  </tr>
679
</table>
680
</td>
681
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
682
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
683
</td>
684
</tr>
685

    
686
<tr>
687
<td bgcolor="white" class="NavBarCell2"><font size="-2">
688
&nbsp;PREV&nbsp;
689
&nbsp;NEXT</font></td>
690
<td bgcolor="white" class="NavBarCell2"><font size="-2">
691
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
692
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
693
&nbsp;&nbsp;
694
<script>
695
  <!--
696
  if(window==top) {
697
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
698
  }
699
  //-->
700
</script>
701
<noscript>
702
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
703
</noscript>
704
</font></td>
705
</tr>
706
</table>
707
<!-- =========== END OF NAVBAR =========== -->
708

    
709
<hr>
710
<font size="-1">
711

    
712
</font>
713
<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>
714
</body>
715
</html>
(248-248/316)