This repository was archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathosm-oljs2.php
More file actions
1022 lines (908 loc) · 47.6 KB
/
osm-oljs2.php
File metadata and controls
1022 lines (908 loc) · 47.6 KB
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
/* (c) Copyright 2015 MiKa (wp-osm-plugin.HanBlog.Net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Osm_OpenLayers
{
//support different types of GML Layers
function addVectorLayer($a_LayerName, $a_FileName, $a_Colour, $a_Type)
{
Osm::traceText(DEBUG_INFO, "addVectorLayer(".$a_LayerName.",".$a_FileName.",".$a_Colour.",".$a_Type.")");
$Layer = '';
// Functions for KML files
$Layer .= ' function osm_'.$a_LayerName.'onPopupClose(evt) {';
$Layer .= ' select.unselectAll();';
$Layer .= ' }';
$Layer .= ' function osm_'.$a_LayerName.'onFeatureSelect(event) {';
$Layer .= ' var feature = event.feature;';
$Layer .= ' var content = "<b>"+feature.attributes.name + "</b> <br>" + feature.attributes.description;';
$Layer .= ' if (content.search("<script") != -1) {';
$Layer .= ' content = "Content contained Javascript! Escaped content below.<br>" + content.replace(/</g, "<");';
$Layer .= ' }';
$Layer .= ' popup = new OpenLayers.Popup.FramedCloud("OSM Plugin",';
$Layer .= ' feature.geometry.getBounds().getCenterLonLat(),';
$Layer .= ' new OpenLayers.Size(200,100),';
$Layer .= ' content,';
$Layer .= ' null, true, osm_'.$a_LayerName.'onPopupClose);';
$Layer .= ' popup.autoSize = true;';
$Layer .= ' feature.popup = popup;';
$Layer .= ' '.$a_LayerName.'.addPopup(popup);';
$Layer .= ' }';
$Layer .= ' function osm_'.$a_LayerName.'onFeatureUnselect(event) {';
$Layer .= ' var feature = event.feature;';
$Layer .= ' if(feature.popup) {';
$Layer .= ' '.$a_LayerName.'.removePopup(feature.popup);';
$Layer .= ' feature.popup.destroy();';
$Layer .= ' delete feature.popup;';
$Layer .= ' } ';
$Layer .= ' }';
// Add the Layer with the GPX Track
$Layer .= ' var lgml = new OpenLayers.Layer.Vector("'.$a_FileName.'",{';
$Layer .= ' strategies: [new OpenLayers.Strategy.Fixed()],';
$Layer .= ' protocol: new OpenLayers.Protocol.HTTP({';
$Layer .= ' url: "'.$a_FileName.'",';
if ($a_Type == 'GPX'){
$Layer .= ' format: new OpenLayers.Format.GPX()';
$Layer .= ' }),';
$Layer .= ' style: {strokeColor: "'.$a_Colour.'", strokeWidth: 5, strokeOpacity: 0.5},';
$Layer .= ' projection: new OpenLayers.Projection("EPSG:4326")';
$Layer .= ' });';
$Layer .= ' '.$a_LayerName.'.addLayer(lgml);';
}
else if ($a_Type == 'KML'){
$Layer .= ' format: new OpenLayers.Format.KML({';
$Layer .= ' extractStyles: true,';
$Layer .= ' extractAttributes: true,';
$Layer .= ' maxDepth: 2})';
$Layer .= ' }),';
$Layer .= ' style: {strokeColor: "'.$a_Colour.'", strokeWidth: 5, strokeOpacity: 0.5},';
$Layer .= ' projection: new OpenLayers.Projection("EPSG:4326")';
$Layer .= ' });';
$Layer .= ' '.$a_LayerName.'.addLayer(lgml);';
//+++
$Layer .= ' select = new OpenLayers.Control.SelectFeature(lgml);';
$Layer .= ' lgml.events.on({';
$Layer .= ' "featureselected": osm_'.$a_LayerName.'onFeatureSelect,';
$Layer .= ' "featureunselected": osm_'.$a_LayerName.'onFeatureUnselect';
$Layer .= ' });';
$Layer .= ' '.$a_LayerName.'.addControl(select);';
$Layer .= ' select.activate(); ';
// $Layer .= ' map.zoomToExtent(new OpenLayers.Bounds(68.774414,11.381836,123.662109,34.628906));';
}
return $Layer;
}
function addGoogleTileLayer($a_LayerName, $a_Type){
$Layer = '';
if ($a_Type == 'GooglePhysical'){
$Layer .= '
var '.$a_LayerName.' = new OpenLayers.Map("'.$a_LayerName.'", {projection: "EPSG:3857", displayProjection: "EPSG:4326",
layers: [new OpenLayers.Layer.Google("Google Physical",
{type: google.maps.MapTypeId.TERRAIN, zoomMethod: null, animationEnabled: false, numZoomLevels: 23, MAX_ZOOM_LEVEL: 22}),
new OpenLayers.Layer.Vector("OSM-plugin",{attribution:" <a href=\"http://wp-osm-plugin.hanblog.net\">OSM-Plugin<br><br></a>"})]});
';
}
else if ($a_Type == 'GoogleStreet'){
$Layer .= '
var '.$a_LayerName.' = new OpenLayers.Map(
"'.$a_LayerName.'",
{projection: "EPSG:3857",
displayProjection: "EPSG:4326",
layers: [new OpenLayers.Layer.Google("Google Streets",
{zoomMethod: null, animationEnabled: false, numZoomLevels: 23, MAX_ZOOM_LEVEL: 22}),
new OpenLayers.Layer.Vector("OSM-plugin",{attribution:" <a href=\"http://wp-osm-plugin.hanblog.net\">OSM-Plugin<br><br></a>"})]});
';
}
else if ($a_Type == 'GoogleHybrid'){
$Layer .= '
var '.$a_LayerName.' = new OpenLayers.Map("'.$a_LayerName.'", {projection: "EPSG:3857", displayProjection: "EPSG:4326",
layers: [new OpenLayers.Layer.Google("Google Hybrid",
{type: google.maps.MapTypeId.HYBRID, zoomMethod: null, animationEnabled: false, numZoomLevels: 23, MAX_ZOOM_LEVEL: 22}),
new OpenLayers.Layer.Vector("OSM-plugin",{attribution:" <a href=\"http://wp-osm-plugin.hanblog.net\">OSM-Plugin<br><br></a>"})]});
';
}
else if ($a_Type == 'GoogleSatellite'){
$Layer .= '
var '.$a_LayerName.' = new OpenLayers.Map("'.$a_LayerName.'", {projection: "EPSG:3857", displayProjection: "EPSG:4326",
layers: [new OpenLayers.Layer.Google("Google Satellite",
{type: google.maps.MapTypeId.SATELLITE, zoomMethod: null, animationEnabled: false, numZoomLevels: 23, MAX_ZOOM_LEVEL: 22}),
new OpenLayers.Layer.Vector("OSM-plugin",{attribution:" <a href=\"http://wp-osm-plugin.hanblog.net\">OSM-Plugin<br><br></a>"})]});
';
}
else if ($a_Type == 'AllGoogle'){
$Layer .= '
var '.$a_LayerName.' = new OpenLayers.Map("'.$a_LayerName.'", {
projection: "EPSG:3857", displayProjection: "EPSG:4326",
layers: [
new OpenLayers.Layer.Google(
"Google Physical",
{type: google.maps.MapTypeId.TERRAIN, zoomMethod: null}
),
new OpenLayers.Layer.Google(
"Google Streets",
{numZoomLevels: 20, zoomMethod: null}
),
new OpenLayers.Layer.Google(
"Google Hybrid",
{type: google.maps.MapTypeId.HYBRID, numZoomLevels: 20, zoomMethod: null}
),
new OpenLayers.Layer.Google(
"Google Satellite",
{type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22, zoomMethod: null}
),
new OpenLayers.Layer.Vector("OSM-plugin",{attribution:" <a href=\"http://wp-osm-plugin.hanblog.net\">OSM-Plugin<br><br></a>"})
]});
'.$a_LayerName.'.addControl(new OpenLayers.Control.LayerSwitcher());
';
}
else {// ERROR => set to default
$Layer .= '
var '.$a_LayerName.' = new OpenLayers.Map("'.$a_LayerName.'", {projection: "EPSG:3857"});
var Street = new OpenLayers.Layer.Google("Google Streets", {numZoomLevels: 20});
'.$a_LayerName.'.addLayers([Street]);
';
}
return $Layer;
}
// support different types of GML Layers
function addTileLayer($a_LayerName, $a_Type, $a_OverviewMapZoom, $a_MapControl, $a_ExtType, $a_ExtName, $a_ExtAddress, $a_ExtInit, $a_theme)
{
Osm::traceText(DEBUG_INFO, "addTileLayer(".$a_LayerName.",".$a_Type.",".$a_OverviewMapZoom.")");
$Layer = '';
if ($a_theme == 'private'){
$Layer .= ' OpenLayers.ImgPath = "'.OSM_OPENLAYERS_THEMES_URL.'";';
}
else {
$Layer .= ' OpenLayers.ImgPath = "'.OSM_PLUGIN_THEMES_URL.$a_theme.'/";';
}
$Layer .= ' '.$a_LayerName.' = new OpenLayers.Map ("'.$a_LayerName.'", {';
$Layer .= ' controls:[';
if (($a_MapControl[0] != 'off') && (strtolower($a_Type)!= 'ext')) {
$Layer .= ' new OpenLayers.Control.Navigation(),';
$Layer .= ' new OpenLayers.Control.PanZoom(),';
$Layer .= ' new OpenLayers.Control.Attribution()';
}
else if (($a_MapControl[0] == 'off') && (strtolower($a_Type)!= 'ext')){
$Layer .= ' new OpenLayers.Control.Attribution()';
}
else if (($a_MapControl[0] != 'off') && (strtolower($a_Type)== 'ext')){
$Layer .= ' new OpenLayers.Control.Navigation(),';
$Layer .= ' new OpenLayers.Control.PanZoom(),';
$Layer .= ' new OpenLayers.Control.Attribution()';
}
else if (($a_MapControl[0] == 'off') && (strtolower($a_Type)== 'ext')){
// there is nothing to do
}
else {
Osm::traceText(DEBUG_ERROR, "addOsmLayer(".$a_MapControl[0].",".$a_Type.")");
}
$Layer .= ' ],';
$Layer .= ' maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),';
$Layer .= ' maxResolution: 156543.0399,';
$Layer .= ' numZoomLevels: 19,';
$Layer .= ' units: "m",';
$Layer .= ' projection: new OpenLayers.Projection("EPSG:900913"),';
$Layer .= ' displayProjection: new OpenLayers.Projection("EPSG:4326")';
$Layer .= ' } );';
if (($a_Type == 'AllOsm') || ($a_Type == 'All')){
$Layer .= 'var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");';
$Layer .= 'var layerCycle = new OpenLayers.Layer.OSM.CycleMap("CycleMap");';
//$Layer .= 'var layerOSM_Attr = new OpenLayers.Layer.Vector("OSM-plugin",{attribution:"<a href=\"http://wp-osm-plugin.hanblog.net\">OSM plugin</a>"});';
$Layer .= ''.$a_LayerName.'.addLayers([layerMapnik, layerCycle]);';
$Layer .= ''.$a_LayerName.'.addControl(new OpenLayers.Control.LayerSwitcher());';
}
else if ($a_Type == 'basemap_at'){
// Create a WMTS layer, with given matrix IDs.
$Layer .= 'var matrixIds = new Array(18);';
$Layer .= 'for (var i=0; i<=18; ++i) {';
$Layer .= ' matrixIds[i] = new Object();';
$Layer .= ' matrixIds[i].identifier = "" + i;';
$Layer .= '} ';
$Layer .= 'var layerosm = new OpenLayers.Layer.OSM.Mapnik("Mapnik");';
$Layer .= 'var layerbasemap_at = new OpenLayers.Layer.WMTS({
url: "'.Osm_BaseMap_Tiles.'{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png",
name: "basemap.at",
layer: "geolandbasemap",
style: "normal",
matrixSet: "google3857",
requestEncoding: "REST",
matrixIds: matrixIds,
tileOptions: {crossOriginKeyword: null},
transitionEffect: "resize"
});
';
$Layer .= 'layerbasemap_at.metadata = {link: "http://www.basemap.at/"};';
$Layer .= 'var layerOSM_Attr = new OpenLayers.Layer.Vector("OSM-plugin",{attribution:"<a href=\"http://basemap.at\">basemap.at</a> and <a href=\"http://wp-osm-plugin.hanblog.net\">OSM-Plugin</a>"});';
$Layer .= ''.$a_LayerName.'.addLayers([layerbasemap_at, layerosm, layerOSM_Attr]);';
$Layer .= ''.$a_LayerName.'.addControl(new OpenLayers.Control.LayerSwitcher());';
}
else if ($a_Type == 'OpenSeaMap'){
$Layer .= 'var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");';
$Layer .= 'var layerSeamark = new OpenLayers.Layer.TMS("Seezeichen", "http://t1.openseamap.org/seamark/", { numZoomLevels: 18, type: "png", getURL: getTileURL, tileOptions: {crossOriginKeyword: null}, isBaseLayer: false, displayOutsideMaxExtent: true});';
$Layer .= 'var layerPois = new OpenLayers.Layer.Vector("Haefen", { projection: new OpenLayers.Projection("EPSG:4326"), visibility: true, displayOutsideMaxExtent:true});';
$Layer .= 'layerPois.setOpacity(0.8);';
$Layer .= ''.$a_LayerName.'.addLayers([layerMapnik, layerSeamark, layerPois]);';
$Layer .= ''.$a_LayerName.'.addControl(new OpenLayers.Control.LayerSwitcher());';
}
else if ($a_Type == 'OpenWeatherMap'){
$Layer .= 'var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");';
$Layer .= 'var layerWeather = new OpenLayers.Layer.Vector.OWMWeather("Weather");';
$Layer .= ''.$a_LayerName.'.addLayers([layerMapnik, layerWeather]);';
$Layer .= ''.$a_LayerName.'.addControl(new OpenLayers.Control.LayerSwitcher());';
}
else if ($a_Type == 'OSMRoadsMap'){
$Layer .= 'var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");';
$Layer .= 'var layerCycle = new OpenLayers.Layer.OSM.CycleMap("CycleMap");';
$Layer .= 'var layerOSMRoadsMap = new OpenLayers.Layer.TMS("OSMRoadsMap", "http://openmapsurfer.uni-hd.de/tiles/roads/x={x}&y={y}&z={z}",{ tileOptions: {crossOriginKeyword: null}, isBaseLayer: false});';
$Layer .= 'var layerOSMHillshadeMap = new OpenLayers.Layer.TMS("OSMHillshadeMap", " http://129.206.74.245:8004/tms_hs.ashx?x={x}&y={y}&z={z} ",{ numZoomLevels: 18, type: "png", getURL: getTileURL, tileOptions: {crossOriginKeyword: null}, isBaseLayer: false});';
$Layer .= 'var testlayer = new OpenLayers.Layer.TMS(
"OSM Roads",
"http://openmapsurfer.uni-hd.de/tiles/roads/",
{
numZoomLevels: 20,
type: "png", getURL: getTileURL,
displayOutsideMaxExtent: true,
isBaseLayer: true
}
); ';
$Layer .= 'var layMSNOsmHybrid = new OpenLayers.Layer.TMS(
"OSM Semitransparent",
"http://openmapsurfer.uni-hd.de/tiles/hybrid/",
{
type: "png", getURL: getTileURL,
displayOutsideMaxExtent: true,
isBaseLayer: false
}
); ';
$Layer .= ''.$a_LayerName.'.addLayers([layerMapnik, layerCycle, layMSNOsmHybrid, layerOSMRoadsMap, layerOSMHillshadeMap, testlayer]);';
$Layer .= ''.$a_LayerName.'.addControl(new OpenLayers.Control.LayerSwitcher());';
}
else if ($a_Type == 'stamen_watercolor'){
$Layer .= 'var lmap = new OpenLayers.Layer.OSM.StamenWC("Stamen watercolor");';
$Layer .= ''.$a_LayerName.'.addLayers([lmap]);';
}
else if ($a_Type == 'stamen_toner'){
$Layer .= 'var lmap = new OpenLayers.Layer.OSM.StamenToner("Stamen Toner");';
$Layer .= ''.$a_LayerName.'.addLayers([lmap]);';
}
else{
if ($a_Type == 'Mapnik'){
$Layer .= 'var lmap = new OpenLayers.Layer.OSM.Mapnik("Mapnik");';
$Layer .= ''.$a_LayerName.'.addLayers([lmap]);';
}
if ($a_Type == 'mapnik_ssl'){
$Layer .= 'var lmap = new OpenLayers.Layer.OSM.Mapnik("Mapnik");';
$Layer .= ''.$a_LayerName.'.addLayers([lmap]);';
}
else if ($a_Type == 'CycleMap'){
$Layer .= 'var lmap = new OpenLayers.Layer.OSM.CycleMap("CycleMap");';
$Layer .= ''.$a_LayerName.'.addLayers([lmap]);';
}
else if (($a_Type == 'Ext') || ($a_Type == 'ext')) {
$Layer .= 'var lmap = new OpenLayers.Layer.'.$a_ExtType.'("'.$a_ExtName.'","'.$a_ExtAddress.'",{'.$a_ExtInit.', attribution: "OpenLayers with"});';
$Layer .= 'var layerOSM_Attr = new OpenLayers.Layer.Vector("OSM-plugin",{attribution:"<a href=\"http://wp-osm-plugin.hanblog.net\">OSM plugin</a>"});';
$Layer .= ''.$a_LayerName.'.addLayers([lmap,layerOSM_Attr]);';
}
}
if ($a_MapControl[0] != 'No'){
foreach ( $a_MapControl as $MapControl ){
$MapControl = strtolower($MapControl);
if ( $MapControl == 'scaleline'){
$Layer .= ''.$a_LayerName.'.addControl(new OpenLayers.Control.ScaleLine({geodesic: true}));';
}
elseif ($MapControl == 'scale'){
//$Layer .= ''.$a_LayerName.'.addControl(new OpenLayers.Control.Scale());';
$Layer .= ''.$a_LayerName.'.addControl(new OpenLayers.Control.Scale({geodesic: true}));';
//var scalebar = new OpenLayers.Control.ScaleLine({geodesic: true});
}
elseif ($MapControl == 'mouseposition'){
$Layer .= ''.$a_LayerName.'.addControl(new OpenLayers.Control.MousePosition({displayProjection: new OpenLayers.Projection("EPSG:4326")}));';
}
}
}
// add the overview map
if ($a_OverviewMapZoom >= 0){
$Layer .= 'layer_ov = new OpenLayers.Layer.OSM;';
if ($a_OverviewMapZoom > 0 && $a_OverviewMapZoom < 18 ){
$Layer .= 'var options = {
layers: [layer_ov],
mapOptions: {numZoomLevels: '.$a_OverviewMapZoom.'}
};';
}
else{
$Layer .= 'var options = {layers: [layer_ov]};';
}
$Layer .= ''.$a_LayerName.'.addControl(new OpenLayers.Control.OverviewMap(options));';
}
return $Layer;
}
function AddClickHandler($a_MapName, $a_msgBox, $a_post_id)
{
Osm::traceText(DEBUG_INFO, "AddClickHandler(".$a_msgBox.")");
$a_msgBox = strtolower($a_msgBox);
$Layer = '';
//++
$Layer .= ' var markerslayer = new OpenLayers.Layer.Markers( "Markers" );';
$Layer .= ' '.$a_MapName.'.addLayer(markerslayer);';
//--
$Layer .= 'OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {';
$Layer .= ' defaultHandlerOptions: {';
$Layer .= ' "single": true,';
$Layer .= ' "double": false,';
$Layer .= ' "pixelTolerance": 0,';
$Layer .= ' "stopSingle": false,';
$Layer .= ' "stopDouble": false';
$Layer .= ' },';
$Layer .= ' initialize: function(options) {';
$Layer .= ' this.handlerOptions = OpenLayers.Util.extend(';
$Layer .= ' {}, this.defaultHandlerOptions';
$Layer .= ' );';
$Layer .= ' OpenLayers.Control.prototype.initialize.apply(';
$Layer .= ' this, arguments';
$Layer .= ' );';
$Layer .= ' this.handler = new OpenLayers.Handler.Click(';
$Layer .= ' this, {';
$Layer .= ' "click": this.trigger';
$Layer .= ' }, this.handlerOptions';
$Layer .= ' );';
$Layer .= ' },';
$Layer .= ' trigger: function(e) {';
$Layer .= ' var LayerName = '.$a_MapName.'.baseLayer.name; ';
$Layer .= ' var Centerlonlat = '.$a_MapName.'.getCenter(e.xy).clone();';
$Layer .= ' var Clicklonlat = '.$a_MapName.'.getLonLatFromViewPortPx(e.xy);';
$Layer .= ' var zoom = '.$a_MapName.'.getZoom(e.xy);';
$Layer .= ' Centerlonlat.transform('.$a_MapName.'.getProjectionObject(), '.$a_MapName.'.displayProjection);';
$Layer .= ' Clicklonlat.transform('.$a_MapName.'.getProjectionObject(), '.$a_MapName.'.displayProjection);';
$Layer .= ' Centerlonlat.lat = Math.round( Centerlonlat.lat * 1000. ) / 1000.;'; // mapcenter
$Layer .= ' Centerlonlat.lon = Math.round( Centerlonlat.lon * 1000. ) / 1000.;';
$Layer .= ' Clicklonlat.lat = Math.round( Clicklonlat.lat * 100000. ) / 100000.;';// markerposition
$Layer .= ' Clicklonlat.lon = Math.round( Clicklonlat.lon * 100000. ) / 100000.;';
if ($a_msgBox == 'sc_gen'){
$Layer .= '
div = document.getElementById("ShortCode_Div");
var MarkerName = document.Markerform.osm_marker.value;
var AddFileOption = document.Addfileform.osm_add_file.value;
var BorderColour = osm_getRadioValue("Bordercolourform");
var NaviName = osm_getRadioValue("Naviform");
var CntrStyle = osm_getRadioValue("ControlStyleform");
NaviField = "";
MarkerField = "";
MarkerTextField_01 = "";
MarkerTextField_02 = "";
MarkerTextField_03 = "";
MarkerTextField_04 = "";
FileField = "";
MapControlField = "";
BorderColourField = "";
ControlStyleField = "";
ZIndexField = "";
if (MarkerName != "none"){
MarkerField = " marker=\""+Clicklonlat.lat+","+Clicklonlat.lon+"\" marker_name=\"" + MarkerName + "\"";
if (NaviName != "undefined"){
NaviField = " marker_routing=\""+ NaviName + "\"";
}
if (document.Markertextform.MarkerText_01.value != "Max Mustermann"){
MarkerTextField_01 = " m_txt_01=\""+ document.Markertextform.MarkerText_01.value + "\"";
}
if (document.Markertextform.MarkerText_02.value != "Musterstr. 90"){
MarkerTextField_02 = " m_txt_02=\""+ document.Markertextform.MarkerText_02.value + "\"";
}
if (document.Markertextform.MarkerText_03.value != "1020 Mustercity"){
MarkerTextField_03 = " m_txt_03=\""+ document.Markertextform.MarkerText_03.value + "\"";
}
if (document.Markertextform.MarkerText_04.value != "MusterCountry"){
MarkerTextField_04 = " m_txt_04=\""+ document.Markertextform.MarkerText_04.value + "\"";
}
}'; // if (MarkerName != "none")
$Layer .= '
if ((AddFileOption != "none") && (document.Addfileform.FileURL.value != "http://")){
if (AddFileOption == "kml") {
FileField = " kml_file=\""+ document.Addfileform.FileURL.value + "\"";
}
if (AddFileOption == "gpx_red") {
FileField = " gpx_file=\""+ document.Addfileform.FileURL.value + "\" gpx_colour=\"red\"";
}
if (AddFileOption == "gpx_green") {
FileField = " gpx_file=\""+ document.Addfileform.FileURL.value + "\" gpx_colour=\"green\"";
}
if (AddFileOption == "gpx_blue") {
FileField = " gpx_file=\""+ document.Addfileform.FileURL.value + "\" gpx_colour=\"blue\"";
}
if (AddFileOption == "gpx_black") {
FileField = " gpx_file=\""+ document.Addfileform.FileURL.value + "\" gpx_colour=\"black\"";
}
if (AddFileOption == "text") {
FileField = " marker_file=\""+ document.Addfileform.FileURL.value + "\"";
}
}
';
$Layer .= ' if (CntrStyle != "undefined"){
ControlStyleField = " theme=\""+ CntrStyle + "\"";
}';
$Layer .= ' if (document.ZIndexform.ZIndex.checked){
ZIndexField = " z_index=\""+ document.ZIndexform.ZIndex.value + "\"";
}';
$Layer .= ' if (document.MapControlform.MapControl.checked){
MapControlField = " control=\""+ document.MapControlform.MapControl.value;
}';
$Layer .= ' if (document.MapControlform.Mouseposition.checked){
if (document.MapControlform.MapControl.checked){
MapControlField = MapControlField + "," + document.MapControlform.Mouseposition.value;
}
else{
MapControlField = " control=\""+ document.MapControlform.Mouseposition.value;
}
}';
$Layer .= ' if ((document.MapControlform.Mouseposition.checked) || (document.MapControlform.MapControl.checked)) {';
$Layer .= ' MapControlField = MapControlField + "\"";';
$Layer .= ' }';
$Layer .= ' if (BorderColour != "undefined"){';
$Layer .= ' BorderColourField = " map_border=\"thin solid "+ BorderColour + "\"";';
$Layer .= ' }';
$Layer .= ' div.innerHTML = "[osm_map lat=\"" + Centerlonlat.lat + "\" lon=\"" + Centerlonlat.lon + "\" zoom=\"" + zoom + "\" width=\"100%\" height=\"450\"" + FileField + BorderColourField + MapControlField + MarkerField + MarkerTextField_01 + MarkerTextField_02 + MarkerTextField_03 + MarkerTextField_04 + NaviField + ZIndexField + ControlStyleField + " type=\""+LayerName+"\"]";';
$Layer .= ' markerslayer.clearMarkers();';
$Layer .= ' if (MarkerName != "none"){';
$Layer .= ' var icon_Obj = osm_getIconSize(MarkerName);';
$Layer .= ' var icon_size = new OpenLayers.Size(icon_Obj.width,icon_Obj.height);';
$Layer .= ' var icon_offset = new OpenLayers.Pixel(icon_Obj.offset_width, icon_Obj.offset_height);';
$Layer .= ' var icon_url = "'.OSM_PLUGIN_ICONS_URL.'" + MarkerName;';
$Layer .= ' var click_icon = new OpenLayers.Icon(icon_url,icon_size,icon_offset); ';
$Layer .= ' var icon_lonlat = new OpenLayers.LonLat(Clicklonlat.lon,Clicklonlat.lat).transform('.$a_MapName.'.displayProjection, '.$a_MapName.'.projection);';
$Layer .= ' markerslayer.addMarker(new OpenLayers.Marker(icon_lonlat,click_icon.clone()));';
$Layer .= ' }';
}
else if( $a_msgBox == 'metabox_marker_sc_gen'){
$Layer .= '
MarkerField = "";
ThemeField = "";
MapTypeField = "";
MarkerName = document.post.osm_marker_marker.value;
if (document.post.osm_marker_map_type.value != "Mapnik"){
MapTypeField = " type=\"" + document.post.osm_marker_map_type.value + "\"";
}
if (document.post.osm_marker_marker.value != "none"){
MarkerField = " marker_latlon=\""+Clicklonlat.lat+","+Clicklonlat.lon+"\" marker_name=\"" + MarkerName + "\"";
}
if (document.post.osm_marker_theme.value == "dark"){
ThemeField = " map_border=\"thin solid grey\"";
}
else if (document.post.osm_marker_theme.value == "blue"){
ThemeField = " map_border=\"thin solid blue\"";
}
else if (document.post.osm_marker_theme.value == "orange"){
ThemeField = " map_border=\"thin solid orange\"";
}
GenTxt = "[osm_map_v3 map_center=\"" + Centerlonlat.lat + "," + Centerlonlat.lon + "\" zoom=\"" + zoom + "\" width=\"100%\" height=\"450\" " + ThemeField + MarkerField + MapTypeField + "]";
div = document.getElementById("ShortCode_Div");
div.innerHTML = GenTxt;
';
$Layer .= '
markerslayer.clearMarkers();
if (document.post.osm_marker_marker.value != "none"){
var icon_Obj = osm_getIconSize(MarkerName);
var icon_size = new OpenLayers.Size(icon_Obj.width,icon_Obj.height);
var icon_offset = new OpenLayers.Pixel(icon_Obj.offset_width, icon_Obj.offset_height);
var icon_url = "'.OSM_PLUGIN_ICONS_URL.'" + MarkerName;
var click_icon = new OpenLayers.Icon(icon_url,icon_size,icon_offset);
var icon_lonlat = new OpenLayers.LonLat(Clicklonlat.lon,Clicklonlat.lat).transform('.$a_MapName.'.displayProjection, '.$a_MapName.'.projection);
markerslayer.addMarker(new OpenLayers.Marker(icon_lonlat,click_icon.clone()));
}';
}
else if( $a_msgBox == 'metabox_file_list_sc_gen'){
$Layer .= '
var FileList_ColorField = "";
var FileList_TypeField = "";
var FileList_MapTypeField = "";
var FileList_FileField = "";
var FileList_FileUrl = document.post.osm_file_list_URL.value;
if (document.post.osm_file_list_map_type.value != "Mapnik"){
FileList_MapTypeField = " type=\"" + document.post.osm_file_list_map_type.value + "\"";
}
if (document.post.osm_file_list_color.value != "none"){
FileList_ColorField = " file_color_list=\"" + document.post.osm_file_list_color.value + "\"";
}
FileList_FileField = " file_list=\""+ FileList_FileUrl + "\"";
GenTxt = "[osm_map_v3 map_center=\"" + Centerlonlat.lat + "," + Centerlonlat.lon + "\" zoom=\"" + zoom + "\" width=\"100%\" height=\"450\" " + FileList_FileField + FileList_MapTypeField + FileList_ColorField + "]";
div = document.getElementById("ShortCode_Div");
div.innerHTML = GenTxt;
';
$Layer .= '
markerslayer.clearMarkers();
if ((((document.post.osm_import.value == "single") || (document.post.osm_import.value == "none")) || (document.post.osm_mode.value == "geotagging")) && (document.post.osm_marker.value != "none")){
var icon_Obj = osm_getIconSize(MarkerName);
var icon_size = new OpenLayers.Size(icon_Obj.width,icon_Obj.height);
var icon_offset = new OpenLayers.Pixel(icon_Obj.offset_width, icon_Obj.offset_height);
var icon_url = "'.OSM_PLUGIN_ICONS_URL.'" + MarkerName;
var click_icon = new OpenLayers.Icon(icon_url,icon_size,icon_offset);
var icon_lonlat = new OpenLayers.LonLat(Clicklonlat.lon,Clicklonlat.lat).transform('.$a_MapName.'.displayProjection, '.$a_MapName.'.projection);
markerslayer.addMarker(new OpenLayers.Marker(icon_lonlat,click_icon.clone()));
}';
}
else if( $a_msgBox == 'metabox_file_sc_gen'){
$Layer .= '
var ThemeField = "";
var TypeField = "";
var MapTypeField = "";
var FileField = "";
var AddFileOption = document.post.osm_file_add_file.value;
var FileUrl = document.post.file_FileURL.value;
if (document.post.osm_file_map_type.value != "Mapnik"){
MapTypeField = " type=\"" + document.post.osm_file_map_type.value + "\"";
}
if (document.post.osm_file_theme.value == "dark"){
ThemeField = " control=\"mouseposition,scaleline\" map_border=\"thin solid grey\" theme=\"dark\"";
}
else if (document.post.osm_file_theme.value == "blue"){
ThemeField = " control=\"mouseposition,scaleline\" map_border=\"thin solid blue\" theme=\"ol\"";
}
else if (document.post.osm_file_theme.value == "orange"){
ThemeField = " control=\"mouseposition,scaleline\" map_border=\"thin solid orange\" theme=\"ol_orange\"";
}
if ((AddFileOption != "none") && (document.post.file_FileURL.value != "http://")){
if (AddFileOption == "kml") {
FileField = " kml_file=\""+ FileUrl + "\"";
}
if (AddFileOption == "gpx_red") {
FileField = " gpx_file=\""+ FileUrl + "\" gpx_colour=\"red\"";
}
if (AddFileOption == "gpx_green") {
FileField = " gpx_file=\""+ FileUrl + "\" gpx_colour=\"green\"";
}
if (AddFileOption == "gpx_blue") {
FileField = " gpx_file=\""+ FileUrl + "\" gpx_colour=\"blue\"";
}
if (AddFileOption == "gpx_black") {
FileField = " gpx_file=\""+ FileUrl + "\" gpx_colour=\"black\"";
}
if (AddFileOption == "text") {
FileField = " marker_file=\""+ FileUrl + "\"";
}
}
GenTxt = "[osm_map lat=\"" + Centerlonlat.lat + "\" lon=\"" + Centerlonlat.lon + "\" zoom=\"" + zoom + "\" width=\"100%\" height=\"450\" " + ThemeField + FileField + MapTypeField + "]";
div = document.getElementById("ShortCode_Div");
div.innerHTML = GenTxt;
';
$Layer .= '
markerslayer.clearMarkers();
if ((((document.post.osm_import.value == "single") || (document.post.osm_import.value == "none")) || (document.post.osm_mode.value == "geotagging")) && (document.post.osm_marker.value != "none")){
var icon_Obj = osm_getIconSize(MarkerName);
var icon_size = new OpenLayers.Size(icon_Obj.width,icon_Obj.height);
var icon_offset = new OpenLayers.Pixel(icon_Obj.offset_width, icon_Obj.offset_height);
var icon_url = "'.OSM_PLUGIN_ICONS_URL.'" + MarkerName;
var click_icon = new OpenLayers.Icon(icon_url,icon_size,icon_offset);
var icon_lonlat = new OpenLayers.LonLat(Clicklonlat.lon,Clicklonlat.lat).transform('.$a_MapName.'.displayProjection, '.$a_MapName.'.projection);
markerslayer.addMarker(new OpenLayers.Marker(icon_lonlat,click_icon.clone()));
}';
}
else if( $a_msgBox == 'metabox_geotag_sc_gen'){
$Layer .= '
MarkerField = "";
ThemeField = "";
MapTypeField = "";
Linefield = "";
PostTypeField ="";
var MarkerName = document.post.osm_geotag_marker.value;
if (document.post.osm_geotag_map_type.value != "Mapnik"){
MapTypeField = " type=\"" + document.post.osm_geotag_map_type.value + "\"";
}
if (document.post.osm_geotag_line.value != "none"){
Linefield = " import_osm_line_color=\""+ document.post.osm_geotag_line.value + "\"";
}
if (document.post.osm_geotag_posttype.value != "post"){
PostTypeField = " post_type=\""+document.post.osm_geotag_posttype.value+"\"";
}
if (document.post.osm_geotag_marker.value != "none"){
MarkerField = " marker_name=\"" + MarkerName + "\"";
}
if (document.post.osm_geotag_theme.value == "dark"){
ThemeField = " map_border=\"thin solid grey\" theme=\"dark\"";
}
if (document.post.osm_geotag_theme.value == "blue"){
ThemeField = " map_border=\"thin solid blue\" theme=\"ol\"";
}
if (document.post.osm_geotag_theme.value == "orange"){
ThemeField = " map_border=\"thin solid orange\" theme=\"ol_orange\"";
}
GenTxt = "[osm_map lat=\"" + Centerlonlat.lat + "\" lon=\"" + Centerlonlat.lon + "\" zoom=\"" + zoom + "\" width=\"100%\" height=\"450\" " + "import=\"osm_l\"" + PostTypeField + Linefield + ThemeField + MarkerField + MapTypeField + "]";
div = document.getElementById("ShortCode_Div");
div.innerHTML = GenTxt;
';
}
else if( $a_msgBox == 'metabox_geometry_sc_gen'){
$Layer .= '
MarkerField = "";
ThemeField = "";
TypeField = "";
MapTypeField = "";
var MarkerName = document.post.osm_marker.value;
if (document.post.osm_map_type.value != "none"){
MapTypeField = " type=\""+ document.post.osm_map_type.value + "\"";
}
if ((document.post.osm_import.value != "none") && (document.post.osm_import.value != "single")){
TypeField = " import=\""+ document.post.osm_import.value + "\"";
}
if (document.post.osm_marker.value != "none"){
MarkerField = " marker=\""+Clicklonlat.lat+","+Clicklonlat.lon+"\" marker_name=\"" + MarkerName + "\"";
}
if (document.post.osm_theme.value == "dark"){
ThemeField = " control=\"mouseposition,scaleline\" map_border=\"thin solid grey\" theme=\"dark\"";
}
if (document.post.osm_theme.value == "blue"){
ThemeField = " control=\"mouseposition,scaleline\" map_border=\"thin solid blue\" theme=\"ol\"";
}
if (document.post.osm_theme.value == "orange"){
ThemeField = " control=\"mouseposition,scaleline\" map_border=\"thin solid orange\" theme=\"ol_orange\"";
}
GenTxt = "[osm_map lat=\"" + Centerlonlat.lat + "\" lon=\"" + Centerlonlat.lon + "\" zoom=\"" + zoom + "\" width=\"100%\" height=\"450\" " + ThemeField + MarkerField + TypeField + MapTypeField + "]";
div = document.getElementById("ShortCode_Div");
div.innerHTML = GenTxt;
';
$Layer .= '
markerslayer.clearMarkers();
if ((((document.post.osm_import.value == "single") || (document.post.osm_import.value == "none")) || (document.post.osm_mode.value == "geotagging")) && (document.post.osm_marker.value != "none")){
var icon_Obj = osm_getIconSize(MarkerName);
var icon_size = new OpenLayers.Size(icon_Obj.width,icon_Obj.height);
var icon_offset = new OpenLayers.Pixel(icon_Obj.offset_width, icon_Obj.offset_height);
var icon_url = "'.OSM_PLUGIN_ICONS_URL.'" + MarkerName;
var click_icon = new OpenLayers.Icon(icon_url,icon_size,icon_offset);
var icon_lonlat = new OpenLayers.LonLat(Clicklonlat.lon,Clicklonlat.lat).transform('.$a_MapName.'.displayProjection, '.$a_MapName.'.projection);
markerslayer.addMarker(new OpenLayers.Marker(icon_lonlat,click_icon.clone()));
}';
}
else if( $a_msgBox == 'metabox_geotag_gen'){
$Layer .= '
MarkerField = "";
var MarkerName = document.post.osm_marker_geotag.value;
if (document.post.osm_marker_geotag.value != "none"){
MarkerField = " marker=\""+Clicklonlat.lat+","+Clicklonlat.lon+"\" marker_name=\"" + MarkerName + "\"";
}
osm_ajax_object.lat = Clicklonlat.lat;
osm_ajax_object.lon = Clicklonlat.lon;
osm_ajax_object.post_id = '.$a_post_id.';
if (MarkerName != "none"){
osm_ajax_object.icon = MarkerName;
GenTxt = "Location: "+Clicklonlat.lat+","+Clicklonlat.lon+" <br>Icon: " + MarkerName + "<br><b>3. Press [Save] to store!</b>";
}
else {
GenTxt = "Location: "+Clicklonlat.lat+","+Clicklonlat.lon + "<br><b>3. Press [Save] to store!</b>";
}
div = document.getElementById("Geotag_Div");
div.innerHTML = GenTxt;
';
$Layer .= '
markerslayer.clearMarkers();
if (document.post.osm_marker_geotag.value != "none"){
var icon_Obj = osm_getIconSize(MarkerName);
var icon_size = new OpenLayers.Size(icon_Obj.width,icon_Obj.height);
var icon_offset = new OpenLayers.Pixel(icon_Obj.offset_width, icon_Obj.offset_height);
var icon_url = "'.OSM_PLUGIN_ICONS_URL.'" + MarkerName;
var click_icon = new OpenLayers.Icon(icon_url,icon_size,icon_offset);
var icon_lonlat = new OpenLayers.LonLat(Clicklonlat.lon,Clicklonlat.lat).transform('.$a_MapName.'.displayProjection, '.$a_MapName.'.projection);
markerslayer.addMarker(new OpenLayers.Marker(icon_lonlat,click_icon.clone()));
}';
}
else if( $a_msgBox == 'lat_long'){
$Layer .= ' alert("Lat= " + Clicklonlat.lat + " Lon= " + Clicklonlat.lon);';
}
$Layer .= ' }';
$Layer .= ' ';
$Layer .= ' });';
$Layer .= 'var click = new OpenLayers.Control.Click();';
$Layer .= ''.$a_MapName.'.addControl(click);';
$Layer .= 'click.activate();';
return $Layer;
}
function addMarkerListLayer($a_MapName, $Icon ,$a_MarkerArray, $a_DoPopUp)
{
Osm::traceText(DEBUG_INFO, "addMarkerListLayer(".$a_MapName.",".$Icon[name].",".$Icon[width].",".$Icon[height].",".$a_MarkerArray.",".$Icon[offset_width].",".$Icon[offset_height].",".$a_DoPopUp.")");
$Layer = '';
$Layer .= 'var MarkerLayer = new OpenLayers.Layer.Markers("Marker");';
$Layer .= $a_MapName.'.addLayer(MarkerLayer);';
$Layer .= '
function osm_'.$a_MapName.'MarkerPopUpClick(a_evt){
if (this.popup == null){
this.popup = this.createPopup(this.closeBox);
'.$a_MapName.'.addPopup(this.popup);
this.popup.show();
}
else{
for (var i = 0; i < '.$a_MapName.'.popups.length; i++){
'.$a_MapName.'.popups[i].hide();
}
this.popup.toggle();
}
OpenLayers.Event.stop(a_evt);
}
';
$Layer .= 'var '.$a_MapName.'IconArray = [];';
$NumOfMarker = count($a_MarkerArray);
for ($row = 0; $row < $NumOfMarker; $row++){
$Layer .= 'var Mdata = {};';
$Icon_tmp = $Icon;
if ($a_MarkerArray[$row][Marker] != ""){
$IconURL = OSM_PLUGIN_ICONS_URL.$a_MarkerArray[$row][Marker];
if (Osm_icon::isOsmIcon($a_MarkerArray[$row][Marker]) == 1){
$Icon_tmp = Osm_icon::getIconsize($a_MarkerArray[$row][Marker]);
}
else {
// set it do invidual marker
$this->traceText(DEBUG_INFO, "e_not_osm_icon");
$this->traceText(DEBUG_INFO, $a_MarkerArray[$row][Marker]);
}
}
else {
$IconURL = OSM_PLUGIN_ICONS_URL.$Icon[name];
}
$Layer .= '
Mdata.icon = new OpenLayers.Icon("'.$IconURL.'",
new OpenLayers.Size('.$Icon_tmp[width].','.$Icon_tmp[height].'),
new OpenLayers.Pixel('.$Icon_tmp[offset_width].', '.$Icon_tmp[offset_height].'));';
$Layer .= ''.$a_MapName.'IconArray.push(Mdata);';
}
for ($row = 0; $row < $NumOfMarker; $row++){
// add the the backslashes
$OSM_HTML_TEXT = addslashes($a_MarkerArray[$row][text]);
$Layer .= 'var ll = new OpenLayers.LonLat('.$a_MarkerArray[$row][lon].','.$a_MarkerArray[$row][lat].').transform('.$a_MapName.'.displayProjection, '.$a_MapName.'.projection);';
$Layer .= 'var feature = new OpenLayers.Feature(MarkerLayer, ll, '.$a_MapName.'IconArray['.$row.']);';
$Layer .= 'feature.closeBox = true;';
$Layer .= 'feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {"autoSize": true, minSize: new OpenLayers.Size('.$a_MarkerArray[$row][popup_width].','.$a_MarkerArray[$row][popup_height].'),"keepInMap": true } );';
$Layer .= 'feature.data.popupContentHTML = "'.$OSM_HTML_TEXT.'";';
$Layer .= 'feature.data.overflow = "hidden";';
$Layer .= 'var marker = new OpenLayers.Marker(ll,'.$a_MapName.'IconArray['.$row.'].icon.clone());';
$Layer .= 'marker.feature = feature;';
if ($a_DoPopUp == 'true'){
$Layer .= 'marker.events.register("mousedown", feature, osm_'.$a_MapName.'MarkerPopUpClick);';
}
$Layer .= 'MarkerLayer.addMarker(marker);';
// if there is just one marker, let's pop it up
if ($a_DoPopUp == 'true'){
$Layer .= $a_MapName.'.addPopup(feature.createPopup(feature.closeBox));'; // maybe there is a better way to do
if ($NumOfMarker > 1){
$Layer .= 'feature.popup.toggle();'; // it than create and toggle!
}
}
// if (($a_DoPopUp == 'true')&&($NumOfMarker == 1)){
// $Layer .= ''.$a_MapName.'.addPopup(feature.createPopup(feature.closeBox));';
// }
}
return $Layer;
}
//++
function addLineLayer($a_LayerName, $a_MarkerArray)
{
Osm::traceText(DEBUG_INFO, "addLineLayer(".$a_LayerName.")");
$Layer = '';
$Layer .= 'var LonList = new Array() ';
$Layer .= 'var LatList = new Array() ';
$NumOfMarker = count($a_MarkerArray);
for ($ii = 0; $ii < $NumOfMarker; $ii++){
$Layer .= 'LonList['.$ii.']='.$a_MarkerArray[$ii][lon];
$Layer .= 'LatList['.$ii.']='.$a_MarkerArray[$ii][lat];
}
return $Layer;
}
//--
function addTextLayer($a_MapName, $a_MarkerName, $a_marker_file)
{
Osm::traceText(DEBUG_INFO, "addTextLayer(".$a_marker_file.")");
$Layer = '';
$Layer .= 'var pois = new OpenLayers.Layer.Text( "'.$a_MarkerName.'",
{ location:"'.$a_marker_file.'",
projection: '.$a_MapName.'.displayProjection
});';
$Layer .= $a_MapName.'.addLayer(pois);';
return $Layer;
}
/// discs
function addDiscs($centerListArray,$radiusListArray,$centerOpacityListArray,$centerColorListArray,
$borderWidthListArray,$borderColorListArray,$borderOpacityListArray,$fillColorListArray,$fillOpacityListArray,$a_MapName) {
$layer ='var discLayer = new OpenLayers.Layer.Vector("Disc Layer");';
for($i=0;$i<sizeof($centerListArray);$i++){
// $centerListArray[$i] = lon lat -> lon,lat
// only center and radius must be defined for each disc to be shown, else use first/default value (ie [0])
$layer .= 'osm_getFeatureDiscCenter('.$a_MapName.', discLayer,'.implode(",",explode( " ", trim($centerListArray[$i]) )).', '.$radiusListArray[$i].', '.
((isset($centerOpacityListArray[$i]))? $centerOpacityListArray[$i] : $centerOpacityListArray[0]).', "'.
((isset($centerColorListArray[$i]))? $centerColorListArray[$i] : $centerColorListArray[0]).'", '.
((isset($borderWidthListArray[$i]))? $borderWidthListArray[$i] : $borderWidthListArray[0]).', "'.
((isset($borderColorListArray[$i]))? $borderColorListArray[$i] : $borderColorListArray[0]).'", '.
((isset($borderOpacityListArray[$i]))? $borderOpacityListArray[$i] : $borderOpacityListArray[0]).', "'.
((isset($fillColorListArray[$i]))? $fillColorListArray[$i] : $fillColorListArray[0]).'", '.
((isset($fillOpacityListArray[$i]))? $fillOpacityListArray[$i] : $fillOpacityListArray[0]).');';
}
$layer.=' '.$a_MapName.'.addLayer(discLayer);';
return $layer;
}
/// end discs
// lines ++
function addLines($PointListArray,$a_LineColor,$a_LineWidth, $a_MapName)
{
$layer = '';
$layer.='var lineLayer = new OpenLayers.Layer.Vector("Line Layer");';
$layer.='var Points = new Array();';
$layer.='var lineWidth = '.$a_LineWidth.';';
$layer.='var lineColor = "'.$a_LineColor.'";';
for($i=0;$i<sizeof($PointListArray);$i++){
$layer.='Points['.$i.'] = new Object();';
$layer.='Points['.$i.']["lon"] = '.$PointListArray[$i][lon].';';
$layer.='Points['.$i.']["lat"] = '.$PointListArray[$i][lat].';';
}
$layer.=' osm_setLinePoints('.$a_MapName.', lineLayer, lineWidth, lineColor, 0.7, Points);';
$layer.=' '.$a_MapName.'.addLayer(lineLayer);';
return $layer;
}
// //lines --
function setMapCenterAndZoom($a_MapName, $a_lat, $a_lon, $a_zoom)
{
Osm::traceText(DEBUG_INFO, "setMapCenterAndZoom(".$a_lat.",".$a_lon.",".$a_zoom.")");
$Layer = '';
if (strtolower($a_zoom) == ('auto')){
$a_zoom = 'null';
}
if ((strtolower($a_lat) == ('auto')) || (strtolower($a_lon) == ('auto'))) {
$Layer .= 'var lonLat = null;';
}
else {
$Layer .= 'var lonLat = new OpenLayers.LonLat('.$a_lon.','.$a_lat.').transform('.$a_MapName.'.displayProjection, '.$a_MapName.'.projection);';
}
$Layer .= ''.$a_MapName.'.setCenter (lonLat,'.$a_zoom.');'; // Zoomstufe einstellen
return $Layer;
}
function setGoogleMapCenterAndZoom($a_MapName, $a_lat, $a_lon, $a_zoom)
{
Osm::traceText(DEBUG_INFO, "setGoogleMapCenterAndZoom(".$a_lat.",".$a_lon.",".$a_zoom.")");
$Layer = '';
if (strtolower($a_zoom) == ('auto')){
$a_zoom = 'null';
}
if ((strtolower($a_lat) == ('auto')) || (strtolower($a_lon) == ('auto'))) {
$Layer .= 'var lonLat = null;';
}
else {
$Layer .= 'var lonLat = new OpenLayers.LonLat('.$a_lon.','.$a_lat.').transform("EPSG:4326", '.$a_MapName.'.projection);';
}
$Layer .= ''.$a_MapName.'.setCenter (lonLat,'.$a_zoom.');'; // Zoomstufe einstellen
return $Layer;
}
// check the map-type, remove whit space and replace Osnmarender
function checkMapType($a_type){
// Osmarender is replaced by Mapnik
if ($a_type == 'Osmarender'){
return "Mapnik";
}
if ($a_type != 'Mapnik' && $a_type != 'mapnik_ssl' && $a_type != 'CycleMap' && $a_type != 'OpenSeaMap' && $a_type != 'stamen_watercolor' && $a_type != 'stamen_toner' && $a_type != 'OpenWeatherMap' && $a_type != 'OSMRoadsMap' && $a_type != 'basemap_at' && $a_type != 'Google' && $a_type != 'All' && $a_type != 'AllGoogle' && $a_type != 'AllOsm' && $a_type != 'ext' && $a_type != 'GooglePhysical' && $a_type != 'GoogleStreet' && $a_type != 'GoogleHybrid' && $a_type != 'GoogleSatellite' && $a_type != 'Google Physical' && $a_type != 'Google Street' && $a_type != 'Google Hybrid' && $a_type != 'Google Satellite' && $a_type != 'Ext'){
return "AllOsm";
}
// eg "Google Hybrid" => "GoogleHybrid"
$type = preg_replace('/\s+/', '', $a_type);
return $type;
}
// check the num of zoomlevels