forked from OpenSeaMap/online_chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
1175 lines (1043 loc) · 56.9 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
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?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">
<link rel="stylesheet" type="text/css" href="javascript/route/NauticalRoute.css">
<script type="text/javascript" src="./javascript/lib/jquery.js"></script>
<script type="text/javascript" src="./javascript/openlayers/OpenLayers.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>
<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" src="./javascript/lib/he.js"></script>
<script type="text/javascript" src="./javascript/waterdepth-trackpoints.js"></script>
<script type="text/javascript" src="./javascript/geomagjs/cof2Obj.js"></script>
<script type="text/javascript" src="./javascript/geomagjs/geomag.js"></script>
<script type="text/javascript" src="./javascript/mag_deviation.js"></script>
<script type="text/javascript">
<?php
$tempval = parse_ini_file("/var/lib/online-chart/online_chart.ini");
$osm_server = $tempval['osmserver'];
echo "var OsmTileServer = ", "\"", $osm_server, "\""
?>
var map;
// 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 mLat = -1;
var mLon = -1;
//last zoomlevel of the map
var oldZoom = 0;
var downloadName;
var downloadLink;
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
var layer_permalink; // 17
var layer_waterdepth_trackpoints_100m; // 18
var layer_waterdepth_trackpoints_10m; // 21
var layer_waterdepth_contours; // 22
// To not change the permalink layer order, every removed
// layer keeps its number. The ArgParser compares the
// count of layers with the layers argument length. So we
// have to let him know, how many layers are removed.
var ignoredLayers = 2;
// Select controls
var selectControl;
// Controls
var ZoomBar = new OpenLayers.Control.PanZoomBar();
var permalinkControl = new OpenSeaMap.Control.Permalink(null, null, {
ignoredLayers : ignoredLayers
});
// Marker that is pinned at the last location the user searched for and selected.
var searchedLocationMarker = null;
// return array of osm tile server
function GetOsmServer()
{
var retv;
if (OsmTileServer == "BRAVO")
{
retv=['https://t2.openseamap.org/tile/${z}/${x}/${y}.png'];
}
else{
retv=['https://tile.openstreetmap.org/${z}/${x}/${y}.png'];
}
return retv;
}
// 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");
mZoom = getArgument("zoom");
if (buffZoom != -1) {
zoom = buffZoom;
}
if (mZoom != -1) {
zoom = mZoom;
}
if (buffLat != -1 && buffLon != -1) {
lat = buffLat;
lon = buffLon;
}
if (mLat != -1 && mLon != -1) {
lat = mLat;
lon = mLon;
}
drawmap();
layer_marker = new OpenLayers.Layer.Markers("Marker",{
layerId: -2 // invalid layerId -> will be ignored by layer visibility setup
});
map.addLayer(layer_marker);
try{
// Create Marker, if arguments are given
if (mLat != -1 && mLon != -1) {
var mtext = he.encode(decodeURIComponent(getArgument("mtext")))
.replace(/\n/g, '<br/>');
mtext = mtext.replace('<b>', '<b>')
.replace('<%2Fb>', '</b>')
.replace('</b>', '</b>');
addMarker(layer_marker, mLon, mLat, mtext);
}
}catch(err) {
console.log(err)
}
readLayerCookies();
resetLayerCheckboxes();
initMenuTools();
// Set current language for internationalization
OpenLayers.Lang.setCode(language);
}
function readLayerCookies() {
if (getArgument('layers') != -1) {
// There is a 'layers' url param -> ignore cookies
// activate checkbox for deth points if one sublayer is selected
if (layer_waterdepth_trackpoints_10m.visibility ||
layer_waterdepth_trackpoints_100m.visibility)
document.getElementById('checkLayerWaterDepthTrackPoints').checked = true
return;
}
// Set Layer visibility from cookie
var seamarkVisible = getCookie("SeamarkLayerVisible") === "true"
if(getCookie("SeamarkLayerVisible") === "-1")
seamarkVisible = true; // default to visible
layer_seamark.setVisibility(seamarkVisible);
var poisVisible = getCookie("HarbourLayerVisible") === "true"
layer_pois.setVisibility(poisVisible);
var tidalVisible = getCookie("TidalScaleLayerVisible") === "true"
layer_tidalscale.setVisibility(tidalVisible);
if(layer_tidalscale.visibility)
refreshTidalScales();
var sportVisible = getCookie("SportLayerVisible") === "true"
layer_sport.setVisibility(sportVisible);
var gridVisible = getCookie("GridWGSLayerVisible") === "true"
if(getCookie("GridWGSLayerVisible") === "-1")
gridVisible = true; // default to visible
layer_grid.setVisibility(gridVisible);
var gebcoVisible = getCookie("GebcoDepthLayerVisible") === "true"
// layer_gebco_deepshade.setVisibility(gebcoVisible);
layer_gebco_deeps_gwc.setVisibility(gebcoVisible);
var wikiLayerVisible = getCookie("WikipediaLayerVisible") === "true"
var wikiThumbsVisible = getCookie("WikipediaLayerThumbs") === "true"
setWikiThumbs(wikiThumbsVisible)
setWikiLayer(wikiLayerVisible)
if (getCookie("BingAerialLayerVisible") == "true") {
map.setBaseLayer(layer_bing_aerial);
}
var aisVisible = getCookie("AisLayerVisible") === "true"
layer_ais.setVisibility(aisVisible)
var depth10mVisible = getCookie("WaterDepthTrackPointsLayerVisible10m") === "true"
layer_waterdepth_trackpoints_10m.setVisibility(depth10mVisible);
var depth100mVisible = getCookie("WaterDepthTrackPointsLayerVisible100m") === "true"
layer_waterdepth_trackpoints_100m.setVisibility(depth100mVisible);
var contoursVisible = getCookie("WaterDepthContoursVisible") === "true"
layer_waterdepth_contours.setVisibility(contoursVisible);
document.getElementById('checkLayerWaterDepthTrackPoints').checked = depth10mVisible || depth100mVisible
showWaterDepthTrackPoints();
if (getCookie("CompassroseVisible") === "true") {
document.getElementById("checkCompassrose").checked = true
toggleCompassrose();
}
}
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("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("checkPermalink").checked = (layer_permalink.getVisibility() === true);
//document.getElementById("checkLayerSatPro").checked = (layer_satpro.getVisibility() === true);
setWaterDepthBoxes();
document.getElementById("checkDepthContours").checked = (layer_waterdepth_contours.getVisibility() === true);
document.getElementById("checkCompassrose").checked = (document.getElementById("compassRose").style.visibility === 'visible');
createPermaLink();
}
// 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 toggleCompassrose() {
if (document.getElementById("checkCompassrose").checked) {
refreshMagdev();
document.getElementById("compassRose").style.visibility = 'visible';
setCookie("CompassroseVisible", "true");
} else {
document.getElementById("compassRose").style.visibility = 'hidden';
setCookie("CompassroseVisible", "false");
}
}
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();
}
}
function toggleNauticalRoute(show) {
if (show) {
addNauticalRoute();
} else {
closeNauticalRoute();
}
}
function togglePermalink(show) {
if (show) {
addPermalink();
} else {
closePermalink();
}
}
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_deeps_gwc.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");
}
}
function toggleMapDownload(show) {
if (show) {
addMapDownload();
selectControl.removePopup();
} else {
closeMapDownload();
}
}
/// update visual elements based onlayer visibility
function setWaterDepthBoxes(fromClick){
// overwrite checkbox.checked if not comming from an mouse click
if(fromClick !== true){
document.getElementById('checkLayerWaterDepthTrackPoints').checked = layer_waterdepth_trackpoints_10m.visibility || layer_waterdepth_trackpoints_100m.visibility
}
var checked = document.getElementById("checkLayerWaterDepthTrackPoints").checked;
if(!checked){
layer_waterdepth_trackpoints_10m.setVisibility(false);
layer_waterdepth_trackpoints_100m.setVisibility(false);
document.getElementById("license_waterdepth").style.display = 'none';
}else{
if (!layer_waterdepth_trackpoints_10m.visibility &&
!layer_waterdepth_trackpoints_100m.visibility)
layer_waterdepth_trackpoints_10m.setVisibility(true);
document.getElementById("license_waterdepth").style.display = 'inline';
}
document.getElementById("checkLayerWaterDepthTrackPoints10m").checked = layer_waterdepth_trackpoints_10m.visibility
document.getElementById("checkLayerWaterDepthTrackPoints100m").checked = layer_waterdepth_trackpoints_100m.visibility
}
function showWaterDepthTrackPoints(fromClick) {
setWaterDepthBoxes(fromClick)
showWaterDepthTrackPoints10m();
showWaterDepthTrackPoints100m();
}
function showWaterDepthTrackPoints10m() {
if (!layer_waterdepth_trackpoints_10m.visibility) {
layer_waterdepth_trackpoints_10m.setVisibility(false);
setCookie("WaterDepthTrackPointsLayerVisible10m", "false");
} else {
layer_waterdepth_trackpoints_10m.setVisibility(true);
setCookie("WaterDepthTrackPointsLayerVisible10m", "true");
}
}
function showWaterDepthTrackPoints100m() {
if (!layer_waterdepth_trackpoints_100m.visibility) {
layer_waterdepth_trackpoints_100m.setVisibility(false);
setCookie("WaterDepthTrackPointsLayerVisible100m", "false");
} else {
layer_waterdepth_trackpoints_100m.setVisibility(true);
setCookie("WaterDepthTrackPointsLayerVisible100m", "true");
}
}
function showContours() {
var visibleNew = !layer_waterdepth_contours.visibility
layer_waterdepth_contours.setVisibility(visibleNew);
setCookie("WaterDepthContoursVisible", visibleNew);
}
// Show Wikipedia layer
function showWikipediaLinks(sub) {
if (sub) {
var checked = document.getElementById("checkLayerWikipediaThumbnails").checked
setWikiLayer(false); // will be toggled by parent <li onClick>
// toggle thumb display
setWikiThumbs(!checked)
} else {
// toggle wiki layer
setWikiLayer(!layer_wikipedia.getVisibility())
}
}
function setWikiThumbs(active){
wikipediaThumbs = active
setWikiProtocol();
}
function setWikiLayer(visible){
layer_wikipedia.setVisibility(visible);
setCookie("WikipediaLayerVisible", visible);
if(!visible) {
selectControl.removePopup();
}else{
setWikiProtocol()
}
}
function setWikiProtocol(){
setCookie("WikipediaLayerThumbs", wikipediaThumbs);
var displayThumbs = wikipediaThumbs ? 'yes' : 'no';
var iconsProtocol = new OpenLayers.Protocol.HTTP({
url: 'api/proxy-wikipedia.php?',
params: {
'LANG' : language,
'thumbs' : displayThumbs
},
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true
})
});
layer_wikipedia.protocol = iconsProtocol;
}
// 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);
}
function closeMapDownload() {
selectControl.hover = true;
layer_download.setVisibility(false);
layer_download.removeAllFeatures();
closeActionDialog();
}
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 = "https://sourceforge.net/projects/opennautical/files/Maps" + downloadLink + "ONC-" + downloadName + format + "/download";
downloadWindow = window.open(url);
}
function selectedMap (event) {
var feature = event.feature;
downloadName = feature.attributes.name;
downloadLink = feature.attributes.link;
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/delete.png\" width=\"17\" height=\"17\" onclick=\"if (!routeChanged || confirm('<?=$t->tr("confirmDeleteRoute")?>')) {closeNauticalRoute();addNauticalRoute();}\"/> ";
htmlText += "<img src=\"./resources/action/info.png\" width=\"17\" height=\"17\" onClick=\"showMapKey('help-trip-planner');\"/> ";
htmlText += "<img src=\"./resources/action/close.gif\" onClick=\"if (!routeChanged || confirm('<?=$t->tr("confirmCloseRoute")?>')) {closeNauticalRoute();}\"/></div>";
htmlText += "<h3><?=$t->tr("tripPlanner")?>: <input type=\"text\" id=\"tripName\" size=\"20\"></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 id=\"routePoints\" colspan = 2> </td></tr>";
htmlText += "</table>";
htmlText += "<input type=\"button\" id=\"buttonRouteDownloadTrack\" value=\"<?=$t->tr("download")?>\" onclick=\"NauticalRoute_DownloadTrack();\" disabled=\"true\">";
htmlText += "<select id=\"routeFormat\"><option value=\"CSV\"/>CSV<option value=\"GML\"/>GML<option value=\"KML\"/>KML<option value=\"GPX\"/>GPX</select> ";
htmlText += "<select id=\"coordFormat\" onchange=\"NauticalRoute_getPoints(routeTrack);\"><option value=\"coordFormatdms\"/>ggg°mm.mmm'<option value=\"coordFormatd_dec\"/>ggg.gggggg</select> ";
htmlText += "<select id=\"distUnits\" onchange=\"NauticalRoute_getPoints(routeTrack);\"><option value=\"nm\"/>[nm]<option value=\"km\"/>[km]</select>";
showActionDialog(htmlText);
NauticalRoute_startEditMode();
}
function closeNauticalRoute() {
layer_nautical_route.setVisibility(false);
closeActionDialog();
NauticalRoute_stopEditMode();
}
function onAddMarker(e) {
// Marker Init
var size = new OpenLayers.Size(32, 32); // size of the marker
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); // offset to get the pinpoint of the needle to mouse pos
var icon = new OpenLayers.Icon('./resources/icons/Needle_Red_32.png', size, offset); // Init of icon
// Adding of Marker
layer_permalink.clearMarkers(); // clear all markers to only keep one marker at a time on the map
var position = this.events.getMousePosition(e); // get position of mouse click
var lonlat = map.getLonLatFromLayerPx(position); // get Lon/Lat from position
layer_permalink.addMarker(new OpenLayers.Marker(lonlat, icon)); // add maker
// Display Marker Position
lonlat.transform(projMerc, proj4326);
// Code from mousepostion_dm.js - redundant, try to reuse
var ns = lonlat.lat >= 0 ? 'N' : 'S';
var we = lonlat.lon >= 0 ? 'E' : 'W';
var lon_m = Math.abs(lonlat.lon*60).toFixed(3);
var lat_m = Math.abs(lonlat.lat*60).toFixed(3);
var lon_d = Math.floor(lon_m/60);
var lat_d = Math.floor(lat_m/60);
lon_m -= lon_d*60;
lat_m -= lat_d*60;
// Write the specified content inside
OpenLayers.Util.getElement("markerpos").innerHTML = ns + lat_d + "°" + format2FixedLenght(lat_m,6,3) + "'" + " " + we + lon_d + "°" + format2FixedLenght(lon_m,6,3) + "'";
$("#markerpos").data("lat", lonlat.lat.toFixed(5))
$("#markerpos").data("lon", lonlat.lon.toFixed(5))
createPermaLink();
}
function createPermaLink(){
if(!layer_permalink.visibility)
return;
if(!OpenLayers.Util.getElement("permalinkDialog"))
return
// Create Permalink for Layers
var layersPermalink = permalinkControl.getLayerString();
layersPermalink = permalinkControl.setFlag(layersPermalink, 'F', layer_permalink.layerId);
// Generate Permalink for copy and paste
var url = window.location.href;
var userURL = url.substr(0, url.lastIndexOf('/')+1)
userURL += "?zoom=" + map.getZoom(); // add map zoom to string
userURL += "&lat=" + y2lat(map.getCenter().lat).toFixed(5); // add map zoom to string
userURL += "&lon=" + x2lon(map.getCenter().lon).toFixed(5); // add map zoom to string
var lat = $("#markerpos").data("lat")
if(lat)
userURL += "&mlat=" + lat; // add latitude
var lon = $("#markerpos").data("lon")
if(lon)
userURL += "&mlon=" + $("#markerpos").data("lon"); // add longitude
var mText = encodeURIComponent(document.getElementById("markerText").value)
if(mText != "")
userURL += "&mtext=" + mText; // add marker text; if empty OSM-permalink JS will ignore the '&mtext'
userURL += "&layers=" + layersPermalink; // add encoded layers
OpenLayers.Util.getElement("userURL").innerHTML = userURL; // write contents of userURL to textarea
}
function addPermalink() {
layer_permalink.setVisibility(true);
var htmlText = "<div id='permalinkDialog' style=\"position:absolute; top:5px; right:5px; cursor:pointer;\">";
htmlText += "<img src=\"./resources/action/close.gif\" onClick=\"closePermalink();\"/></div>";
htmlText += "<h3><?=$t->tr("permalinks")?>:</h3><br/>"; // reference to translation.php
htmlText += "<p><?=$t->tr("markset")?></p>"
htmlText += "<br /><hr /><br />"
// Übersetzungen in die PHP-Files reinschreiben; kein Text sollte ohne die Möglichkeit der Bearbeitung hier drin stehen
htmlText += "<table border=\"0\" width=\"370px\">";
htmlText += "<tr><td><?=$t->tr("position")?>:</td><td id=\"markerpos\">- - -</td></tr>"; // Lat/Lon of the user's click
htmlText += "<tr><td><?=$t->tr("description")?>:</td><td><textarea cols=\"25\" rows=\"5\" id=\"markerText\"></textarea></td></tr>"; // userInput
htmlText += "</td></tr></table>";
htmlText += "<br /><hr /><br />"
htmlText += "<?=$t->tr("copynpaste")?>:<br /><textarea onclick=\"this.select();\" cols=\"50\" rows=\"3\" id=\"userURL\"></textarea>"; // secure & convient onlick-solution for copy and paste
showActionDialog(htmlText);
$('#markerText').on('keyup', function(evt) {
createPermaLink()
});
map.events.register("click", layer_permalink, onAddMarker);
createPermaLink();
}
function closePermalink() {
map.events.unregister("click", layer_permalink, onAddMarker);
layer_permalink.setVisibility(false);
closeActionDialog();
}
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=\"jumpToSearchedLocation(" + placeLon + ", " + placeLat + ");\"><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() {
let scaleLineSize = Math.max(0.2*$(window).width(),0.2*$(window).height()).toFixed(0);
map = new OpenLayers.Map('map', {
numZoomLevels : 19,
projection : projMerc,
displayProjection : proj4326,
eventListeners: {
moveend : mapEventMove,
zoomend : mapEventZoom,
click : mapEventClick,
changelayer : mapChangeLayer
},
controls: [
permalinkControl,
new OpenLayers.Control.Navigation(),
//new OpenLayers.Control.LayerSwitcher(), //only for debugging
new OpenLayers.Control.ScaleLine({topOutUnits : "nmi", bottomOutUnits: "km", topInUnits: 'nmi', bottomInUnits: 'km', maxWidth: scaleLineSize, geodesic: true}),
new OpenLayers.Control.MousePositionDM(),
new OpenLayers.Control.OverviewMap(),
ZoomBar
]
});
var bboxStrategyWikipedia = new OpenLayers.Strategy.BBOX( {
ratio : 1.1,
resFactor: 1
});
var poiLayerWikipediaHttp = new OpenLayers.Protocol.HTTP({
url: 'api/proxy-wikipedia.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.XYZ('Mapnik',
GetOsmServer(),
{ layerId : 1,
wrapDateLine : true
});
// Seamark
layer_seamark = new OpenLayers.Layer.TMS("seamarks", "https://t1.openseamap.org/seamark/",
{ layerId: 3, numZoomLevels: 19, type: 'png', getURL:getTileURL, isBaseLayer:false, displayOutsideMaxExtent:true});
// Sport
layer_sport = new OpenLayers.Layer.TMS("Sport", "https://t1.openseamap.org/sport/",
{ layerId: 4, numZoomLevels: 19, type: 'png', getURL:getTileURL, isBaseLayer:false, visibility: false, displayOutsideMaxExtent:true});
//GebcoDepth
layer_gebco_deeps_gwc = new OpenLayers.Layer.WMS("gebco_2021", "https://depth.openseamap.org/geoserver/gwc/service/wms",
{layers: "gebco2021:gebco_2021", format:"image/png"},
{ layerId: 6, isBaseLayer: false, visibility: false, opacity: 0.8});
// POI-Layer for harbours
layer_pois = new OpenLayers.Layer.Vector("pois", {
layerId: 7,
visibility: true,
projection: proj4326,
displayOutsideMaxExtent:true
});
// Bing
layer_bing_aerial = new Bing({
layerId: 12,
name: 'Aerial photo',
key: 'AuA1b41REXrEohfokJjbHgCSp1EmwTcW8PEx_miJUvZERC0kbRnpotPTzGsPjGqa',
type: 'Aerial',
isBaseLayer: true,
displayOutsideMaxExtent: true,
wrapDateLine: 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: true,
zoomUnits: zoomUnits
});
layer_wikipedia = new OpenLayers.Layer.Vector("Wikipedia World", {
layerId: 11,
visibility: false,
projection: proj4326,
strategies: [bboxStrategyWikipedia],
protocol: poiLayerWikipediaHttp
});
layer_ais = new OpenLayers.Layer.TMS("Marinetraffic", "https://tiles.marinetraffic.com/ais_helpers/shiptilesingle.aspx?output=png&sat=1&grouping=shiptype&tile_size=512&legends=1&zoom=${z}&X=${x}&Y=${y}",
{ layerId: 13, numZoomLevels: 19, type: 'png', getURL:getTileURLMarine, isBaseLayer:false, displayOutsideMaxExtent:true, tileSize : new OpenLayers.Size(512,512)
});
// SatPro
satPro = new SatPro(map, selectControl, {
layerId: 14
});
layer_satpro = satPro.getLayer();
// Disaster (15)
// POI-Layer for tidal scales
layer_tidalscale = new OpenLayers.Layer.Vector("tidalscale", {
layerId: 16,
visibility: false,
projection: proj4326,
displayOutsideMaxExtent:true
});
// Permalink
layer_permalink = new OpenLayers.Layer.Markers("Permalink", {
layerId: 17,
visibility: false,
projection: proj4326
});
// Water Depth
waterDepthTrackPoints10m = new WaterDepthTrackPoints10m(map, selectControl, {
layerId: 21
});
layer_waterdepth_trackpoints_10m = waterDepthTrackPoints10m.getLayer();
waterDepthTrackPoints100m = new WaterDepthTrackPoints100m(map, selectControl, {
layerId: 18
});
layer_waterdepth_trackpoints_100m = waterDepthTrackPoints100m.getLayer();
layer_waterdepth_contours = new OpenLayers.Layer.WMS("Contours", "http:///osm.franken.de/cgi-bin/mapserv.fcgi?",
{
layers: ['contour','contour2'],
numZoomLevels: 22,
projection: this.projectionMercator,
type: 'png',
transparent: true},
{ layerId: 22, isBaseLayer: false, visibility: false,tileSize: new OpenLayers.Size(1024,1024), });
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_permalink,
layer_waterdepth_trackpoints_10m,
layer_waterdepth_trackpoints_100m,
layer_waterdepth_contours,
]);
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 = [];
layer_pois.removeAllFeatures();
}
function clearTidalScaleLayer() {
arrayTidalScales = [];
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) {