NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/Chameleon/trunk/Chameleon/WMSBrowser/mapbrowser_template_fr.html

Revision 13 (checked in by jcleary, 17 years ago)

Latest Chameleon code checkout from previous repository

Line 
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
3 <html>
4
5
6
7 <cwc2 type="Language" >
8
9   <language name="en-CA" template="mapbrowser_template_en.html"/>
10
11   <language name="fr-CA" template="mapbrowser_template_fr.html"/>
12
13 </cwc2>
14
15
16
17 <head>
18
19 <title>Map Browser</title>
20
21 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
22
23 <link href="[$gszCoreWebPath$]/skins/default/css/cwc2.css" rel="stylesheet" type="text/css">
24
25 <link href="[$gszCoreWebPath$]/widgets/css/mapbrowser.css" rel="stylesheet" type="text/css">
26
27 <style type="text/css">
28
29
30
31 div
32
33 {
34
35   font-family : Arial, Helvetica, sans-serif;
36
37   font-size : 11px;
38
39 }
40
41
42
43 .label
44
45 {
46
47   font-family : Arial, Helvetica, sans-serif;
48
49   font-size : 11px;
50
51 }
52
53
54
55 </style>
56
57
58
59 <!-- custom javascript to hook it all together -->
60
61 <script language="JavaScript" type="text/JavaScript">
62
63 var browser ="";
64
65 var version = "";
66
67
68
69 var aExtents = "";
70
71 var aSelectedLayers = new Array();
72
73 var currentLayer = "";
74
75
76
77 if (navigator.appName == "Netscape")
78
79 {
80
81     browser = "netscape";
82
83     if ( navigator.appVersion[0] <= 4)
84
85       version = 4;
86
87     else
88
89       version = 5;
90
91 }
92
93 else
94
95 {
96
97     browser = "ie";
98
99 }
100
101
102
103 /**
104
105  * called when the page loads
106
107  */
108
109 function myOnLoad()
110
111 {
112
113 }
114
115
116
117 document.onkeyup = myOnKeyUp;
118
119
120
121 if (browser == "netscape")
122
123   document.captureEvents(Event.KEYUP);
124
125
126
127 function myOnKeyUp( e )
128
129 {
130
131   var key, sel, layer_id, i, j, nRemoved;
132
133   if (browser == "netscape")
134
135   {
136
137     key = e.which
138
139   }
140
141   else if (browser == "ie")
142
143   {
144
145     e = event;
146
147       key = e.keyCode;
148
149       e.returnValue = false;
150
151   }
152
153
154
155   if (key == 46)
156
157   {
158
159     sel = document.forms[0].selectList;
160
161     nRemoved = 0;
162
163     for (j=0; j < sel.options.length; j++)
164
165     {
166
167       if (sel.options[j].selected)
168
169       {
170
171         layer_id = sel.options[j].value;
172
173         sel.options[j] = null;
174
175         for (j=0; j < aSelectedLayers.length; j++)
176
177         {
178
179           if (aSelectedLayers[j] == layer_id)
180
181           {
182
183             aSelectedLayers[j] = null;
184
185             nRemoved ++;
186
187             break;
188
189           }
190
191         }
192
193       }
194
195     }
196
197     var aNewLayers = new Array();
198
199     for (i=0; i < aSelectedLayers.length; i++)
200
201     {
202
203       if (aSelectedLayers[i] !== null)
204
205       {
206
207         aNewLayers[aNewLayers.length] = aSelectedLayers[i];
208
209       }
210
211     }
212
213     aSelectedLayers = aNewLayers;
214
215     document.forms[0].selectedLayers.value = aSelectedLayers.toString();
216
217   }
218
219
220
221   return false;
222
223 }
224
225
226
227 function setExtents()
228
229 {
230
231     aExtents = new Array();
232
233     aExtents[0] = document.forms[0].minx.value;
234
235     aExtents[1] = document.forms[0].miny.value;
236
237     aExtents[2] = document.forms[0].maxx.value;
238
239     aExtents[3] = document.forms[0].maxy.value;
240
241     previewLayer( currentLayer );
242
243 }
244
245
246
247 function clearExtents()
248
249 {
250
251     aExtents = "";
252
253     previewLayer( currentLayer );
254
255 }
256
257
258
259 /**
260
261  * handle the user changing WMS Servers by 'telling' the two wms cache
262
263  * widgets which server to consider 'active'
264
265  */
266
267 function myOnChange( obj, opt )
268
269 {
270
271     document.forms[0].WMSSERVERS.value = opt.value;
272
273     document.forms[0].WMSLAYERS.value = opt.value;
274
275     document.forms[0].submit();
276
277 }
278
279
280
281 /*
282
283  * this function is called when a layer is clicked in the tree.
284
285  * the function scans the shared resource for the layer id and
286
287  * then updates the abstract and puts the layer in the map for previewing
288
289  *
290
291  * layer_id - a unique value from the wms cache.
292
293  */
294
295 function myTreeClicked( layer_id )
296
297 {
298
299   layer_id = parseInt( String(layer_id) );
300
301     var sr = goJSSR.GetValue( "WMSLAYERS" ).maoChildren[0];
302
303     var child = mySearch( sr, layer_id );
304
305
306
307     if (child != null)
308
309     {
310
311         currentLayer = child;
312
313
314
315         var szAbstract = "<strong>Abstract:</strong>&nbsp;";
316
317         szAbstract = szAbstract + child.GetValue("title") + "<br>\n";
318
319
320
321         szAbstract = szAbstract + child.GetValue( "abstract" );
322
323
324
325         ShowContents( "abstract", szAbstract );
326
327
328
329         if (previewLayer( child, sr ))
330
331         {
332
333
334
335           //add to selected layers
336
337           var j;
338
339           bSelect = true;
340
341           for (j=0; j < aSelectedLayers.length; j++)
342
343           {
344
345               if (aSelectedLayers[j] == layer_id)
346
347               {
348
349                   bSelect = false;
350
351                   break;
352
353               }
354
355           }
356
357           if (bSelect)
358
359           {
360
361               aSelectedLayers[aSelectedLayers.length] = layer_id;
362
363               opt = new Option();
364
365               opt.text = child.GetValue( "title" );
366
367               opt.value = layer_id;
368
369               document.forms[0].selectList.options[document.forms[0].selectList.options.length] = opt;
370
371           }
372
373           document.forms[0].selectedLayers.value = aSelectedLayers.toString();
374
375       }
376
377     }
378
379     else
380
381     {
382
383         ShowContents( "abstract", "<strong>Abstract:</strong>&nbsp;Select a layer." );
384
385     }
386
387 }
388
389
390
391 function previewLayer( child, sr )
392
393 {
394
395     var szName = child.GetValue( "name" );
396
397     var szTitle = child.GetValue( "title" );
398
399
400
401     //catch servers and themes that are not viewable
402
403     if (szName == "" || child.GetValue( "server_id" ) != "" )
404
405     {
406
407         //alert( "Cannot add " + szTitle + ", it is not a valid WMS layer" );
408
409         return false;
410
411     }
412
413     else
414
415     {
416
417       showActivityLayer();
418
419         //sr still refers to the server that owns this layer.
420
421         var szSRS = sr.GetValue( "srs" );
422
423         if( szSRS.indexOf( " " ) != -1)
424
425             szSRS = szSRS.substr( 0, szSRS.indexOf( " " ) );
426
427         var szConnection = sr.GetValue( "map_url" );
428
429         var szVersion = sr.GetValue( "version" );
430
431         var szFormat = sr.GetValue( "format" );
432
433         //build the WMS connection string
434
435         var szURL = szConnection;
436
437         if (szURL.lastIndexOf( "?" ) == -1)
438
439         {
440
441             //need to add ?
442
443             szURL = szURL + "?";
444
445         }
446
447         else if (szURL.substr( -1 ) != "?" && szURL.substr( -1 ) != "&"-90 )
448
449         {
450
451             //need to add &
452
453             szURL = szURL + "&";
454
455         }
456
457         szURL = szURL + "service=WMS&";
458
459         szURL = szURL + "version=" + szVersion + "&";
460
461         szURL = szURL + "request=GetMap&";
462
463         szURL = szURL + "SRS=EPSG:4326&";
464
465         if (aExtents != "")
466
467         {
468
469             szURL = szURL + "BBOX="+ aExtents.toString() +"&";
470
471         }
472
473         else
474
475         {
476
477             var bbox = child.GetValue( "bbox" );
478
479             aBBox = bbox.split( "," );
480
481             document.forms[0].minx.value = aBBox[0];
482
483             document.forms[0].miny.value = aBBox[1];
484
485             document.forms[0].maxx.value = aBBox[2];
486
487             document.forms[0].maxy.value = aBBox[3];
488
489
490
491             szURL = szURL + "BBOX="+ bbox+"&";
492
493         }
494
495         szURL = szURL + "width=220&";
496
497         szURL = szURL + "height=220&";
498
499         szURL = szURL + "layers=" + szName + "&";
500
501         szURL = szURL + "styles=&";
502
503         szURL = szURL + "format=" + szFormat + "&";
504
505         szURL = szURL + "exceptions=application/vnd.ogc.se_inimage";
506
507         document.images.mapimage.src = szURL;
508
509         return true;
510
511     }
512
513 }
514
515
516
517 /**
518
519  * this function searches the shared resource for the layer that was clicked.
520
521  */
522
523 function mySearch( sr, value )
524
525 {
526
527     var i;
528
529     var result = null;
530
531
532
533     if (sr.GetValue( "layer_id" ) == value)
534
535     {
536
537       result = sr;
538
539     }
540
541     else
542
543     {
544
545         if (sr.maoChildren.length > 0)
546
547         {
548
549             for (i=0; result == null && i < sr.maoChildren.length; i++)
550
551             {
552
553                 result = mySearch( sr.maoChildren[i], value );
554
555             }
556
557         }
558
559     }
560
561     return result;
562
563 }
564
565
566
567 function showActivityLayer()
568
569 {
570
571     document.images.activity.src = "[$gszCoreWebPath$]/skins/default/images/spinner.gif";
572
573 }
574
575
576
577 function hideActivityLayer()
578
579 {
580
581     document.images.activity.src = "[$gszCoreWebPath$]/skins/default/images/a_pixel.gif";
582
583 }
584
585
586
587 function UTLGetLayerForContents(name)
588
589 {
590
591     if (browser == "netscape")
592
593     {
594
595         if (version == "4")
596
597         {
598
599             return document.layers[name];
600
601         }
602
603         else
604
605         {
606
607             if (eval('document.getElementById("' + name + '")') != null)
608
609             {
610
611                 layer = eval('document.getElementById("' + name + '")');
612
613                 return layer;
614
615             }
616
617             else
618
619             {
620
621                 return null;
622
623             }
624
625         }
626
627     }
628
629
630
631     else if (browser == "ie")
632
633     {
634
635         if (eval('document.all.' + name) != null)
636
637         {
638
639             layer = eval('document.all.' + name);
640
641             return layer;
642
643         }
644
645         else
646
647         {
648
649             return null;
650
651         }
652
653     }
654
655 }
656
657
658
659 function ShowContents(szLayerName,szContents)
660
661 {
662
663      oLayer = UTLGetLayerForContents(szLayerName);
664
665      if (browser == "netscape" && version == 4)
666
667      {
668
669          oLayer.document.open();
670
671          oLayer.document.write(szContents);
672
673          oLayer.document.close();
674
675      }
676
677      else
678
679      {
680
681          oLayer.innerHTML = szContents;
682
683      }
684
685 }
686
687
688
689 //:TODO: make a widget that generates this fn
690
691 function CallBackFunc(actionId, aSelectedLayers)
692
693 {
694
695     window.opener.BrowseWMSCallBack(actionId, window);
696
697 }
698
699 </script>
700
701
702
703 </head>
704
705
706
707 <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="myOnLoad()">
708
709 <form name="form1" method="post" action="">
710
711 <table border="0" cellspacing="0" cellpadding="8">
712
713   <tr valign="top">
714
715     <td class="bevel2"><iframe frameborder="0" id="treeview" scrolling="No" width="330px" height="335px"  src="?template=mapbrowser_iframe_fr.html&sid=[$SID$]"/>" ></iframe></td>
716
717     <td class="bevel3"><table width="230" border="0" cellpadding="0" cellspacing="4">
718
719       <tr>
720
721         <td width="100%">&nbsp;</td>
722
723         <td nowrap><span class="label">max x:</span></td>
724
725         <td><input type="text" value="" name="maxx" size="6"></td>
726
727       </tr>
728
729       <tr>
730
731         <td width="100%">&nbsp;</td>
732
733         <td nowrap><span class="label">max y:</span></td>
734
735         <td><input type="text" value="" name="maxy" size="6"></td>
736
737       </tr>
738
739     </table>
740
741       <table border="0" cellpadding="0" cellspacing="0">
742
743         <tr>
744
745           <td>
746
747             <div id="ActivityLayer" style="position:absolute;width:220;height:220">
748
749               <table border="0" cellpadding="1" cellspacing="4" width="220" height="220">
750
751                 <tr>
752
753                   <td valign="center" align="center">
754
755                     <img name="activity" width="216" height="50" src="../images/spinner.gif">
756
757                   </td>
758
759                 </tr>
760
761               </table>
762
763             </div>
764
765           </td>
766
767         </tr>
768
769         <tr>
770
771           <td width="220" height="220" align="center" class="rbevel4"><img name="mapimage" src="[$gszCoreWebPath$]/skins/default/images/a_pixel.gif" width="220" height="220" border="1" onload="hideActivityLayer()" onerror="hideActivityLayer()"></td>
772
773         </tr>
774
775       </table>
776
777       <table width="230" border="0" cellpadding="0" cellspacing="4">
778
779       <tr>
780
781         <td nowrap><span class="label">min x:</span></td>
782
783         <td><input type="text" value="" name="minx" size="6"></td>
784
785         <td width="100%" align="right"><input type="button" onclick="setExtents();" value="Set Extents"></td>
786
787       </tr>
788
789       <tr>
790
791         <td nowrap><span class="label">min y:</span></td>
792
793         <td><input type="text" value="" name="miny" size="6"></td>
794
795         <td width="100%" align="right"><input type="button" onclick="clearExtents();" value="Reset Extents"></td>
796
797       </tr>
798
799       </table>
800
801       </td>
802
803   </tr>
804
805   <tr>
806
807   </tr>
808
809   <tr>
810
811     <td colspan="2" class="bevel2">
812
813       <div class="rbevel2" id="abstract" style="position:relative; width:100%; height:100px; overflow: scroll;"><strong>Abstract:</strong>&nbsp;Select a layer.</div>
814
815     </td>
816
817   </tr>
818
819   <tr>
820
821      <td class="bevel2" colspan="2">
822
823        <span class="label"><strong>Selected Layers</strong><br>
824
825          <select class="layerSelector" name="selectList" size="4" multiple style="width:100%">
826
827          </select>
828
829        </span>
830
831     </td>
832
833   </tr>
834
835   <tr>
836
837     <td colspan="2" align="right">
838
839       <table width="60" border="0" cellpadding="4" cellspacing="0">
840
841         <tr>
842
843           <td width="24"><A HREF="javascript:CallBackFunc(0, aSelectedLayers)"><IMG SRC="[$gszCoreWebPath$]/widgets/WMSBrowser/icon_txt_addselected.gif" alt="Add Selected Layers" title="Add Selected Layers" width="85" height="22" border="0"></A></td>
844
845           <td width="24"><A HREF="javascript:CallBackFunc(1, aSelectedLayers)"><IMG SRC="[$gszCoreWebPath$]/widgets/WMSBrowser/icon_txt_close.gif" alt="Cancel" title="Cancel" width="52" height="22" border="0"></A></td>
846
847         </tr>
848
849       </table>
850
851     </td>
852
853   </tr>
854
855 </table>
856
857 <input type="hidden" name="selectedLayers" value="" size=80>
858
859 </form>
860
861 </body>
862
863 </html>
864
Note: See TracBrowser for help on using the browser.