forked from OpenSeaMap/online_chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
803 lines (737 loc) · 30.2 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
<?php
include("classes/Translation.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>OpenSeaMap - <?php echo $t->tr("dieFreieSeekarte")?></title>
<meta name="AUTHOR" content="Olaf Hannemann">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="content-language" content="<?= $t->getCurrentLanguage()?>">
<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta name="date" content="2012-06-02">
<link rel="SHORTCUT ICON" href="resources/icons/OpenSeaMapLogo_16.png">
<link rel="stylesheet" type="text/css" href="map-full.css">
<link rel="stylesheet" type="text/css" href="topmenu.css">
<script type="text/javascript" src="./javascript/openlayers/OpenLayers.js"></script>
<script type="text/javascript" src="./javascript/OpenStreetMap.js"></script>
<script type="text/javascript" src="./javascript/prototype.js"></script>
<script type="text/javascript" src="./javascript/translation-<?=$t->getCurrentLanguageSafe()?>.js"></script>
<script type="text/javascript" src="./javascript/permalink.js"></script>
<script type="text/javascript" src="./javascript/utilities.js"></script>
<script type="text/javascript" src="./javascript/countries.js"></script>
<script type="text/javascript" src="./javascript/map_utils.js"></script>
<script type="text/javascript" src="./javascript/harbours.js"></script>
<script type="text/javascript" src="./javascript/nominatim.js"></script>
<script type="text/javascript" src="./javascript/tidal_scale.js"></script>
<script type="text/javascript" src="./javascript/route/NauticalRoute.js"></script>
<script type="text/javascript" src="./javascript/mouseposition_dm.js"></script>
<script type="text/javascript" src="./javascript/grid_wgs.js"></script>
<!-- Actual bing class from devel tree (can be removed on next OpenLayers release) -->
<script type="text/javascript" src="./javascript/bing.js"></script>
<script type="text/javascript" src="./javascript/ais.js"></script>
<script type="text/javascript" src="./javascript/satpro.js"></script>
<script type="text/javascript">
var map;
var arrayMaps = new Array();
// Position and zoomlevel of the map (will be overriden with permalink parameters or cookies)
var lon = 11.6540;
var lat = 54.1530;
var zoom = 10;
// marker position
var mlon = -1;
var mlat = -1;
//last zoomlevel of the map
var oldZoom = 0;
var downloadName;
var downloadLink;
var downloadLoaded = false;
var wikipediaThumbs = false;
// FIXME: Work around for accessing translations from harbour.js
var linkTextSkipperGuide = "<?=$t->tr('descrSkipperGuide')?>";
var linkTextWeatherHarbour = "<?=$t->tr('descrOpenPortGuide')?>";
// FIXME: Work around for accessing translations from tidal_scale.js
var linkTextHydrographCurve = "<?=$t->tr('hydrographCurve')?>";
var linkTextMeasuringValue = "<?=$t->tr('measuringValue')?>";
var linkTextTendency = "<?=$t->tr('tendency')?>";
// FIXME: Work around for accessing translations from NauticalRoute.js
var tableTextNauticalRouteCoordinate = "<?=$t->tr('coordinate')?>";
var tableTextNauticalRouteCourse = "<?=$t->tr('course')?>";
var tableTextNauticalRouteDistance = "<?=$t->tr('distance')?>";
// Set language
var language = "<?=$t->getCurrentLanguage()?>";
// Layers
var layer_mapnik; // 1
var layer_marker; // 2
var layer_seamark; // 3
var layer_sport; // 4
var layer_gebco_deepshade; // 5
var layer_gebco_deeps_gwc; // 6
var layer_pois; // 7
var layer_download; // 8
var layer_nautical_route; // 9
var layer_grid; // 10
var layer_wikipedia; // 11
var layer_bing_aerial; // 12
var layer_ais; // 13
var layer_satpro; // 14
// layer_disaster // 15
var layer_tidalscale; // 16
// Select controls
var selectControl;
// Controls
var ZoomBar = new OpenLayers.Control.PanZoomBar();
// Load map for the first time
function init() {
var buffZoom = parseInt(getCookie("zoom"));
var buffLat = parseFloat(getCookie("lat"));
var buffLon = parseFloat(getCookie("lon"));
mlat = getArgument("mlat");
mlon = getArgument("mlon");
if (buffZoom != -1) {
zoom = buffZoom;
}
if (buffLat != -1 && buffLon != -1) {
lat = buffLat;
lon = buffLon;
}
drawmap();
// Create Marker, if arguments are given
if (mlat != -1 && mlon != -1) {
layer_marker = new OpenLayers.Layer.Markers("Marker",{
layerId: 2
});
map.addLayer(layer_marker);
addMarker(layer_marker, mlon, mlat, convert2Text(getArgument("mtext")));
}
readLayerCookies();
resetLayerCheckboxes();
// Set current language for internationalization
OpenLayers.Lang.setCode(language);
}
function readLayerCookies() {
if (getArgument('layers') != -1) {
// There is a 'layers' url param -> ignore cookies
return;
}
// Set Layer visibility from cookie
if (getCookie("SeamarkLayerVisible") == "false") {
layer_seamark.setVisibility(false);
}
if (getCookie("HarbourLayerVisible") == "false") {
layer_pois.setVisibility(false);
}
if (getCookie("TidalScaleLayerVisible") == "true") {
layer_tidalscale.setVisibility(true);
refreshTidalScales();
}
if (getCookie("SportLayerVisible") == "true") {
layer_sport.setVisibility(true);
}
if (getCookie("GridWGSLayerVisible") == "true") {
layer_grid.setVisibility(true);
}
if (getCookie("GebcoDepthLayerVisible") == "true") {
layer_gebco_deepshade.setVisibility(true);
layer_gebco_deeps_gwc.setVisibility(true);
}
if (getCookie("WikipediaLayerVisible") == "true") {
showWikipediaLinks(true, false);
}
if (getCookie("BingAerialLayerVisible") == "true") {
map.setBaseLayer(layer_bing_aerial);
}
if (getCookie("AisLayerVisible") == "true") {
showAis();
}
}
function resetLayerCheckboxes()
{
// This method is separated from readLayerCookies because
// the permalink control also will set the visibility of
// layers.
document.getElementById("checkLayerSeamark").checked = (layer_seamark.getVisibility() === true);
document.getElementById("checkLayerHarbour").checked = (layer_pois.getVisibility() === true);
document.getElementById("checkLayerTidalScale").checked = (layer_tidalscale.getVisibility() === true);
document.getElementById("checkLayerSport").checked = (layer_sport.getVisibility() === true);
document.getElementById("checkLayerGridWGS").checked = (layer_grid.getVisibility() === true);
document.getElementById("checkLayerGebcoDepth").checked = (layer_gebco_deepshade.getVisibility() === true || layer_gebco_deeps_gwc.getVisibility() === true);
document.getElementById("checkDownload").checked = (layer_download.getVisibility() === true);
document.getElementById("checkNauticalRoute").checked = (layer_nautical_route.getVisibility() === true);
document.getElementById("checkLayerWikipedia").checked = (layer_wikipedia.getVisibility() === true);
document.getElementById("checkLayerWikipediaMarker").checked = (layer_wikipedia.getVisibility() === true && wikipediaThumbs === false);
document.getElementById("checkLayerWikipediaThumbnails").checked = (layer_wikipedia.getVisibility() === true && wikipediaThumbs === true);
document.getElementById("checkLayerBingAerial").checked = (map.baseLayer == layer_bing_aerial);
document.getElementById("checkLayerAis").checked = (layer_ais.getVisibility() === true);
//document.getElementById("checkLayerSatPro").checked = (layer_satpro.getVisibility() === true);
}
// Show popup window for help
function showMapKey(item) {
legendWindow = window.open("legend.php?lang=" + language + "&page=" + item, "MapKey", "width=760, height=680, status=no, scrollbars=yes, resizable=yes");
legendWindow.focus();
}
function showSeamarks() {
if (layer_seamark.visibility) {
layer_seamark.setVisibility(false);
setCookie("SeamarkLayerVisible", "false");
} else {
layer_seamark.setVisibility(true);
setCookie("SeamarkLayerVisible", "true");
}
}
function showHarbours() {
if (layer_pois.visibility) {
clearPoiLayer();
layer_pois.setVisibility(false);
setCookie("HarbourLayerVisible", "false");
} else {
layer_pois.setVisibility(true);
setCookie("HarbourLayerVisible", "true");
refreshHarbours();
}
}
function showTidalScale() {
if (layer_tidalscale.visibility) {
clearTidalScaleLayer();
layer_tidalscale.setVisibility(false);
setCookie("TidalScaleLayerVisible", "false");
} else {
layer_tidalscale.setVisibility(true);
setCookie("TidalScaleLayerVisible", "true");
refreshTidalScales();
}
}
// Show route section
function showNauticalRoute() {
if (layer_nautical_route.visibility) {
closeNauticalRoute();
} else {
addNauticalRoute();
}
}
function showSport() {
if (layer_sport.visibility) {
layer_sport.setVisibility(false);
setCookie("SportLayerVisible", "false");
} else {
layer_sport.setVisibility(true);
setCookie("SportLayerVisible", "true");
}
}
function showGridWGS() {
if (layer_grid.visibility) {
layer_grid.setVisibility(false);
setCookie("GridWGSLayerVisible", "false");
} else {
layer_grid.setVisibility(true);
setCookie("GridWGSLayerVisible", "true");
}
}
function showGebcoDepth() {
if (layer_gebco_deepshade.visibility) {
layer_gebco_deepshade.setVisibility(false);
layer_gebco_deeps_gwc.setVisibility(false);
setCookie("GebcoDepthLayerVisible", "false");
} else {
layer_gebco_deepshade.setVisibility(true);
layer_gebco_deeps_gwc.setVisibility(true);
setCookie("GebcoDepthLayerVisible", "true");
}
}
function showBingAerial() {
if (map.baseLayer == layer_bing_aerial) {
map.setBaseLayer(layer_mapnik);
setCookie("BingAerialLayerVisible", "false");
} else {
map.setBaseLayer(layer_bing_aerial);
setCookie("BingAerialLayerVisible", "true");
}
correctBingVisibility();
}
function correctBingVisibility() {
if (map.baseLayer == layer_bing_aerial) {
document.getElementById("license_bing").style.display = 'inline';
layer_bing_aerial.redraw();
} else {
document.getElementById("license_bing").style.display = 'none';
}
}
function showAis() {
if (layer_ais.visibility) {
layer_ais.setVisibility(false);
document.getElementById("license_marine_traffic").style.display = 'none';
setCookie("AisLayerVisible", "false");
} else {
layer_ais.setVisibility(true);
document.getElementById("license_marine_traffic").style.display = 'inline';
setCookie("AisLayerVisible", "true");
}
}
function showSatPro() {
if (layer_satpro.visibility) {
layer_satpro.setVisibility(false);
setCookie("SatProLayerVisible", "false");
} else {
layer_satpro.setVisibility(true);
setCookie("SatProLayerVisible", "true");
}
}
function showDisaster() {
if (layer_disaster.visibility) {
layer_disaster.setVisibility(false);
setCookie("DisasterLayerVisible", "false");
} else {
layer_disaster.setVisibility(true);
setCookie("DisasterLayerVisible", "true");
}
}
// Show Download section
function showMapDownload() {
if (!downloadLoaded) {
addMapDownload();
selectControl.removePopup();
} else {
closeMapDownload();
}
}
// Show Wikipedia layer
function showWikipediaLinks(thumbs, sub) {
if (sub) {
if (thumbs) {
var displayThumbs = 'yes';
setCookie("WikipediaLayerThumbs", "true");
} else {
var displayThumbs = 'no';
setCookie("WikipediaLayerThumbs", "false");
}
if (wikipediaThumbs === false && thumbs === true) {
wikipediaThumbs = true;
layer_wikipedia.setVisibility(false);
} else if (wikipediaThumbs === true && thumbs === false) {
wikipediaThumbs = false;
layer_wikipedia.setVisibility(false);
} else {
wikipediaThumbs = thumbs;
}
var iconsProtocol = new OpenLayers.Protocol.HTTP({
url: 'http://toolserver.org/~kolossos/geoworld/marks.php?',
params: {
'LANG' : language,
'thumbs' : displayThumbs
},
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true
})
});
layer_wikipedia.protocol = iconsProtocol;
} else {
if (layer_wikipedia.getVisibility() === true) {
layer_wikipedia.setVisibility(false);
selectControl.removePopup();
setCookie("WikipediaLayerVisible", "false");
} else {
layer_wikipedia.setVisibility(true);
setCookie("WikipediaLayerVisible", "true");
}
}
}
// Show dialog window
function showActionDialog(htmlText) {
document.getElementById("actionDialog").style.visibility = 'visible';
document.getElementById("actionDialog").innerHTML=""+ htmlText +"";
}
// Hide dialog window
function closeActionDialog() {
document.getElementById("actionDialog").style.visibility = 'hidden';
}
function addMapDownload() {
selectControl.hover = false;
addDownloadlayer();
layer_download.setVisibility(true);
var htmlText = "<div style=\"position:absolute; top:5px; right:5px; cursor:pointer;\"><img src=\"./resources/action/close.gif\" onClick=\"closeMapDownload();\"/></div>";
htmlText += "<h3><?=$t->tr("downloadChart")?>:</h3><br/>";
htmlText += "<table border=\"0\" width=\"240px\">";
htmlText += "<tr><td>Name:</td><td><div id=\"info_dialog\"> <?=$t->tr("pleaseSelect")?><br/></div></td></tr>";
htmlText += "<tr><td><?=$t->tr("format")?>:</td><td><select id=\"mapFormat\"><option value=\"unknown\"/><?=$t->tr("unknown")?><option value=\"png\"/>png<option value=\"cal\"/>cal<option value=\"kap\"/>kap<option value=\"WCI\"/>WCI<option value=\"kmz\"/>kmz<option value=\"jpr\"/>jpr</select></td></tr>";
htmlText += "<tr><td><br/><input type=\"button\" id=\"buttonMapDownload\" value=\"<?=$t->tr("download")?>\" onclick=\"downloadMap()\" disabled=\"true\"></td><td align=\"right\"><br/><input type=\"button\" id=\"buttonMapClose\" value=\"<?=$t->tr("close")?>\" onclick=\"closeMapDownload()\"></td></tr>";
htmlText += "</table>";
showActionDialog(htmlText);
downloadLoaded = true;
}
function closeMapDownload() {
selectControl.hover = true;
layer_download.setVisibility(false);
layer_download.removeAllFeatures();
closeActionDialog();
downloadLoaded = false;
}
function downloadMap() {
var format = document.getElementById("mapFormat").value;
if (format == "unknown") {
alert("Bitte wählen sie ein Format.");
return;
} else if (format == "cal") {
format = "_png." + format
} else {
format = "." + format
}
var url = "http://sourceforge.net/projects/opennautical/files/Maps" + downloadLink + "ONC-" + downloadName + format + "/download";
downloadWindow = window.open(url);
}
function selectedMap (event) {
var feature = event.feature;
var selectedMap = feature.id.split(".");
var buff = arrayMaps[selectedMap[2].split("_")[1]].split(":");
downloadName = buff[0];
downloadLink = buff[1];
var mapName =downloadName;
document.getElementById('info_dialog').innerHTML=""+ mapName +"";
document.getElementById('buttonMapDownload').disabled=false;
}
function addNauticalRoute() {
layer_nautical_route.setVisibility(true);
var htmlText = "<div style=\"position:absolute; top:5px; right:5px; cursor:pointer;\">";
htmlText += "<img src=\"./resources/action/info.png\" width=\"17\" height=\"17\" onClick=\"showMapKey('help-trip-planner');\"/> ";
htmlText += "<img src=\"./resources/action/close.gif\" onClick=\"closeNauticalRoute();\"/></div>";
htmlText += "<h3><?=$t->tr("tripPlanner")?>:</h3><br/>";
htmlText += "<table border=\"0\" width=\"370px\">";
htmlText += "<tr><td><?=$t->tr("start")?></td><td id=\"routeStart\">- - -</td></tr>";
htmlText += "<tr><td><?=$t->tr("finish")?></td><td id=\"routeEnd\">- - -</td></tr>";
htmlText += "<tr><td><?=$t->tr("distance")?></td><td id=\"routeDistance\">- - -</td></tr>";
htmlText += "<tr><td><?=$t->tr("format")?></td><td><select id=\"routeFormat\"><option value=\"CSV\"/>CSV<option value=\"GML\"/>GML<option value=\"KML\"/>KML</select></td></tr>";
htmlText += "<tr><td id=\"routePoints\" colspan = 2> </td></tr>";
htmlText += "<tr><td><br/><input type=\"button\" id=\"buttonRouteDownloadTrack\" value=\"<?=$t->tr("download")?>\" onclick=\"NauticalRoute_DownloadTrack();\" disabled=\"true\"></td><td align=\"right\"><br/><input type=\"button\" id=\"buttonNauticalRouteClear\" value=\"Clear\" onclick=\"closeNauticalRoute();addNauticalRoute();\"> <input type=\"button\" id=\"buttonActionDialogClose\" value=\"<?=$t->tr("close")?>\" onclick=\"closeNauticalRoute();\"></td></tr></table>";
showActionDialog(htmlText);
NauticalRoute_startEditMode();
}
function closeNauticalRoute() {
layer_nautical_route.setVisibility(false);
closeActionDialog();
NauticalRoute_stopEditMode();
}
function addSearchResults(xmlHttp) {
var items = xmlHttp.responseXML.getElementsByTagName("place");
var placeName, description, placeLat, placeLon;
var buff, pos;
var htmlText = "<div style=\"position:absolute; top:5px; right:5px; cursor:pointer;\"><img src=\"./resources/action/close.gif\" onClick=\"closeActionDialog();\"/></div>";
htmlText += "<h3><?=$t->tr("searchResults")?>:</h3><br/>"
htmlText += "<table border=\"0\" width=\"370px\">"
for(i = 0; i < items.length; i++) {
buff = xmlHttp.responseXML.getElementsByTagName('place')[i].getAttribute('display_name');
placeLat = xmlHttp.responseXML.getElementsByTagName('place')[i].getAttribute('lat');
placeLon = xmlHttp.responseXML.getElementsByTagName('place')[i].getAttribute('lon');
pos = buff.indexOf(",");
placeName = buff.substring(0, pos);
description = buff.substring(pos +1).trim();
htmlText += "<tr style=\"cursor:pointer;\" onmouseover=\"this.style.backgroundColor = '#ADD8E6';\"onmouseout=\"this.style.backgroundColor = '#FFF';\" onclick=\"jumpTo(" + placeLon + ", " + placeLat + ", " + zoom + ");\"><td valign=\"top\"><b>" + placeName + "</b></td><td>" + description + "</td></tr>";
}
htmlText += "<tr><td> </td><td align=\"right\"><br/><input type=\"button\" id=\"buttonMapClose\" value=\"<?=$t->tr("close")?>\" onclick=\"closeActionDialog();\"></td></tr></table>";
showActionDialog(htmlText);
}
function drawmap() {
map = new OpenLayers.Map('map', {
projection: projMerc,
displayProjection: proj4326,
eventListeners: {
moveend: mapEventMove,
zoomend: mapEventZoom,
click: mapEventClick,
changelayer: mapChangeLayer
},
controls: [
new OpenSeaMap.Control.Permalink(),
new OpenLayers.Control.Navigation(),
//new OpenLayers.Control.LayerSwitcher(), //only for debugging
new OpenLayers.Control.ScaleLine({topOutUnits : "nmi", bottomOutUnits: "km", topInUnits: 'nmi', bottomInUnits: 'km', maxWidth: '40'}),
new OpenLayers.Control.MousePositionDM(),
new OpenLayers.Control.OverviewMap(),
ZoomBar
],
maxExtent:
new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
numZoomLevels: 19,
maxResolution: 156543,
units: 'meters'
});
// Set proxy url for accessing cross side domains
OpenLayers.ProxyHost = './api/wikipedia-proxy/index.php?q=';
var bboxStrategyWikipedia = new OpenLayers.Strategy.BBOX( {
ratio : 1.1,
resFactor: 1
});
var poiLayerWikipediaHttp = new OpenLayers.Protocol.HTTP({
url: 'http://toolserver.org/~kolossos/geoworld/marks.php?',
params: {
'LANG' : language,
'thumbs' : 'no'
},
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true
})
});
// Select feature ---------------------------------------------------------------------------------------------------------
// (only one SelectFeature per map is allowed)
selectControl = new OpenLayers.Control.SelectFeature([],{
hover:true,
popup:null,
addLayer:function(layer){
var layers = this.layers;
if (layers) {
layers.push(layer);
} else {
layers = [
layer
];
}
this.setLayer(layers);
},
removePopup:function(){
if (this.popup) {
this.map.removePopup(this.popup);
this.popup.destroy();
this.popup = null;
}
}
});
// Add Layers to map-------------------------------------------------------------------------------------------------------
// Mapnik (Base map)
layer_mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
layerId: 1
});
// Seamark
layer_seamark = new OpenLayers.Layer.TMS("seamarks", "http://t1.openseamap.org/seamark/",
{ layerId: 3, numZoomLevels: 19, type: 'png', getURL:getTileURL, isBaseLayer:false, displayOutsideMaxExtent:true});
// Sport
layer_sport = new OpenLayers.Layer.TMS("Sport", "http://tiles.openseamap.org/sport/",
{ layerId: 4, numZoomLevels: 19, type: 'png', getURL:getTileURL, isBaseLayer:false, visibility: false, displayOutsideMaxExtent:true});
//GebcoDepth
layer_gebco_deepshade = new OpenLayers.Layer.WMS("deepshade", "http:///osm.franken.de:8080/geoserver/wms",
{layers: "gebco:deepshade", projection: new OpenLayers.Projection("EPSG:900913"), type: 'png', transparent: true},
{ layerId: 5, isBaseLayer: false, visibility: false, opacity: 0.2, minResolution: 38.22});
layer_gebco_deeps_gwc = new OpenLayers.Layer.WMS("deeps_gwc", "http://osm.franken.de:8080/geoserver/gwc/service/wms",
{layers: "gebco_new", format:"image/jpeg"},
{ layerId: 6, isBaseLayer: false, visibility: false, opacity: 0.4});
// POI-Layer for harbours and tidal scales
layer_pois = new OpenLayers.Layer.Vector("pois", {
layerId: 7,
visibility: true,
projection: proj4326,
displayOutsideMaxExtent:true
});
// Bing
layer_bing_aerial = new OpenLayers.Layer.Bing({
layerId: 12,
name: 'Aerial photo',
key: 'AuA1b41REXrEohfokJjbHgCSp1EmwTcW8PEx_miJUvZERC0kbRnpotPTzGsPjGqa',
type: 'Aerial',
isBaseLayer: true,
displayOutsideMaxExtent: true
});
// Map download
layer_download = new OpenLayers.Layer.Vector("Map Download", {
layerId: 8,
visibility: false
});
// Trip planner
layer_nautical_route = new OpenLayers.Layer.Vector("Trip Planner",
{ layerId: 9, styleMap: routeStyle, visibility: false, eventListeners: {"featuresadded": NauticalRoute_routeAdded, "featuremodified": NauticalRoute_routeModified}});
// Grid WGS
layer_grid = new OpenLayers.Layer.GridWGS("coordinateGrid", {
layerId: 10,
visibility: false,
zoomUnits: zoomUnits
});
layer_wikipedia = new OpenLayers.Layer.Vector("Wikipedia World", {
layerId: 11,
visibility: false,
projection: proj4326,
strategies: [bboxStrategyWikipedia],
protocol: poiLayerWikipediaHttp
});
// AIS (from zoom level 8 upwards)
ais = new Ais(map, selectControl, {
layerId: 13
});
layer_ais = ais.getLayer();
// SatPro
satPro = new SatPro(map, selectControl, {
layerId: 14
});
layer_satpro = satPro.getLayer();
// Disaster (15)
// POI-Layer for harbours and tidal scales
layer_tidalscale = new OpenLayers.Layer.Vector("tidalscale", {
layerId: 16,
visibility: false,
projection: proj4326,
displayOutsideMaxExtent:true
});
map.addLayers([
layer_mapnik,
layer_bing_aerial,
layer_gebco_deepshade,
layer_gebco_deeps_gwc,
layer_seamark,
layer_grid,
layer_pois,
layer_tidalscale,
layer_wikipedia,
layer_nautical_route,
layer_sport,
layer_ais,
layer_satpro,
layer_download
]);
layer_mapnik.events.register("loadend", null, function(evt) {
// The Bing layer will only be displayed correctly after the
// base layer is loaded.
window.setTimeout(correctBingVisibility, 10);
});
if (!map.getCenter()) {
jumpTo(lon, lat, zoom);
}
// Register featureselect for download tool
selectControl.addLayer(layer_download);
layer_download.events.register("featureselected", layer_download, selectedMap);
// Register featureselect for poi layers
selectControl.addLayer(layer_nautical_route);
layer_nautical_route.events.register("featureselected", layer_nautical_route, onFeatureSelectPoiLayers);
selectControl.addLayer(layer_pois);
layer_pois.events.register("featureselected", layer_pois, onFeatureSelectPoiLayers);
selectControl.addLayer(layer_tidalscale);
layer_tidalscale.events.register("featureselected", layer_tidalscale, onFeatureSelectPoiLayers);
selectControl.addLayer(layer_wikipedia);
layer_wikipedia.events.register("featureselected", layer_wikipedia, onFeatureSelectPoiLayers);
// Activate select control
map.addControl(selectControl);
selectControl.activate();
}
function clearPoiLayer() {
harbours.clear();
layer_pois.removeAllFeatures();
}
function clearTidalScaleLayer() {
arrayTidalScales.clear();
layer_tidalscale.removeAllFeatures();
}
function onFeatureSelectPoiLayers(event) {
feature = event.feature;
if (feature.layer == layer_nautical_route) {
feature.style = style_edit;
} else {
selectControl.removePopup();
if (feature.data.popupContentHTML) {
var buff = feature.data.popupContentHTML;
} else {
var buff = '<b>'+feature.attributes.name +'</b><br>'+ feature.attributes.description;
}
popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
null,
buff,
null,
true
);
selectControl.popup = popup;
map.addPopup(popup);
}
}
// Map event listener moved
function mapEventMove(event) {
// Set cookie for remembering lat lon values
setCookie("lat", y2lat(map.getCenter().lat).toFixed(5));
setCookie("lon", x2lon(map.getCenter().lon).toFixed(5));
// Update harbour layer
if (layer_pois.getVisibility() === true) {
refreshHarbours();
}
// Update tidal scale layer
if (layer_tidalscale.getVisibility() === true) {
refreshTidalScales();
}
}
// Map event listener Zoomed
function mapEventZoom(event) {
zoom = map.getZoom();
// Set cookie for remembering zoomlevel
setCookie("zoom",zoom);
// Clear POI layer
clearPoiLayer();
clearTidalScaleLayer();
if(oldZoom!=zoom) {
oldZoom=zoom;
}
if (downloadLoaded) {
closeMapDownload();
addMapDownload();
}
}
function mapEventClick(event) {
selectControl.removePopup();
}
// Map event listener changelayer
function mapChangeLayer(event) {
resetLayerCheckboxes();
}
function addDownloadlayer(xmlMaps) {
var xmlDoc=loadXMLDoc("./gml/map_download.xml");
try {
var root = xmlDoc.getElementsByTagName("maps")[0];
var items = root.getElementsByTagName("map");
} catch(e) {
alert("Error (root): "+ e);
return -1;
}
for (var i=0; i < items.length; ++i) {
var item = items[i];
var load = false;
var category =item.getElementsByTagName("category")[0].childNodes[0].nodeValue;
if (zoom <= 7 && category >= 2) {
load = true;
} else if (zoom <= 10 && category >= 4) {
load = true;
} else if (zoom <= 13 && category >= 6) {
load = true;
} else if (zoom <= 18 && category >= 7) {
load = true;
}
if (load) {
try {
var n = item.getElementsByTagName("north")[0].childNodes[0].nodeValue;
var s = item.getElementsByTagName("south")[0].childNodes[0].nodeValue;
var e = item.getElementsByTagName("east")[0].childNodes[0].nodeValue;
var w = item.getElementsByTagName("west")[0].childNodes[0].nodeValue;
} catch(e) {
alert("Error (load): " + e);
return -1;
}
var bounds = new OpenLayers.Bounds(w, s, e, n);
bounds.transform(new OpenLayers.Projection("EPSG:4326"), new
OpenLayers.Projection("EPSG:900913"));
var box = new OpenLayers.Feature.Vector(bounds.toGeometry());
layer_download.addFeatures(box);
var name = item.getElementsByTagName("name")[0].childNodes[0].nodeValue.trim();
var link = item.getElementsByTagName("link")[0].childNodes[0].nodeValue.trim();
arrayMaps[box.id.split("_")[1]] = name + ":" + link;
}
}
}
</script>
</head>
<body onload="init();">
<div id="map" style="position:absolute; bottom:0px; left:0px;"></div>
<div style="position:absolute; bottom:48px; left:12px; cursor:pointer;">
<a id="license_osm" onClick="showMapKey('license')"><img alt="OSM-Logo" src="resources/icons/OSM-Logo-32px.png" height="32px" title="<?=$t->tr("SomeRights")?>"></a>
<a id="license_ccbysa" onClick="showMapKey('license')"><img alt="CC by SA" src="resources/icons/somerights20.png" height="30px" title="<?=$t->tr("SomeRights")?>"></a>
<a id="license_bing" href="http://wiki.openseamap.org/wiki/Bing" target="_blank" style="display:none"><img alt="bing" src="resources/icons/bing.png" height="29px"></a>
<a id="license_marine_traffic" onClick="showMapKey('license')" style="display:none"><img alt="Marine Traffic" src="resources/icons/MarineTrafficLogo.png" height="30px"></a>
</div>
<div id="actionDialog">
<br> not found <br>
</div>
<? include('classes/topmenu.inc'); ?>
</body>
</html>