-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
1313 lines (1226 loc) · 46.1 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
/* zonesWIFI version 0.5.1
copyright : Pierre Béland
octobre 2013, 2017
First version, hackation in Montreal, 2013
2017-04-25 Simplified design
sources : https://github.com/pierzen/zoneswifi/
Nominatim Search : Courtesy of MapQuest
OSM Extraction : Courtesy of Overpass-API Service
Javascript map tool : OpenLayers API 2.13
Base Map : OpenStreetMap Contributors
*/
error_reporting(E_ALL);
// languages in zones wifi
$langues= array("fr","en");
$uri_script=$_SERVER["SCRIPT_URI"];
// Navigator preference - prefered language
$accept_languages=explode(',',$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
//echo $accept_languages;
//echo "debut PHP";
/*
if(isset($_POST['zoom'])) {
$zoom=htmlentities($_POST['zoom']);
echo "PHP: zoom ",$zoom;
//console.log($zoom);
}
if(isset($_POST['lat'])) {
$lat=htmlentities($_POST['lat']);
echo "PHP: lat ",$lat;
//console.log($lat);
}
if(isset($_POST['lon'])) {
$lon=htmlentities($_POST['lon']);
echo "PHP: lon ",$lon;
// console.log($lon);
}
*/
// langue via 1. post (user input selection) or 2. url get
if(isset($_POST['lang'])) {
$_POST['lang']=htmlentities($_POST['lang']);
if (in_array($_POST['lang'], $langues)) {$lang=$_POST['lang']; }
}
if (isset($lang)) {
;// modif via formulaire
}
elseif(isset($_GET["lang"])){
if (!get_magic_quotes_gpc())
{ $_GET["lang"] = addslashes($_GET["lang"]); }
$lang=strtolower($_GET["lang"]);
}
else
{foreach($accept_languages as $accept_lang)
if (in_array(substr($accept_lang,0,2),$langues))
{
$lang=$accept_lang;
break;
}
}
$ua=$_SERVER['HTTP_USER_AGENT'];
if (strstr($ua, 'Android') || strstr($ua, 'iPhone') || strstr($ua, 'iPad') || strstr($ua, 'iPod') || strstr($ua, 'BlackBerry'))
$mobile_os=1;
else
$mobile_os=0;
if ($mobile_os==1)
{$wordsize="11px"; }
else {$wordsize="22px"; }
//echo "PHP: user_agent ", $_SERVER['HTTP_USER_AGENT'], "<br/>";
//echo "PHP: px mobile_os ", $wordsize, $mobile_os, "<br/>";
if (!isset($lang))
{$lang="fr";}
switch ($lang) {
case "en":
break;
case "fr":
break;
default: $lang="fr";
}
//echo "PHP lang=$lang";
// i18n
switch ($lang) {
case "en":
$i18n = array(
"head-title" => "WIFIzones : Map of free Wifi HotSpots",
"head-description" => "This map locates the free Wifi HotSpot zones from OpenStreetMap data (OSM).",
"osm-attribution" => "© <a href=\'http://www.openstreetmap.org/copyright\'>OpenStreetMap contributors</a>",
"Zones Wifi" => "Wifi Zones",
"naviguer" => "
<p>On this Map, the <em class=\"bleu\">Wifi HotSpots</em> icons let's locate the free Wifi HotSpots. Click on the icons to show the description of each facility.
</p>
<p> Search a town and the Wifi HotSpots will be located for the zone. From this point,
zoom-in to see the various Wifi HotSpots and the description of esch facillity.
",
"contribuez" => "
<p>Wifi HotSpots : Service Overpass, ©
<a href=\"#\" onclick=\"lien(\"osm_copyright\");return false;\">OpenStreetMap ODbL</a></p>
<p>Localities : Nominatim Search, courtesy of
<a href=\"#\" onclick=\"lien(\"nominatim_mapquest\");return false;\">MapQuest</a>.</p>
",
"points_wifi" => "Wifi HotSpots",
"msg_wifi_point" => " Wifi Points - Zoom-in to locate these Wifi points.",
"msg_search" => "Search ...",
"rechercher" => "Search",
"localiser" => "Locate me",
"my_location" => "My Location",
"tlocaliser" => "Show your localisation",
"lieu-non-identifie" => "Unknown facility"
);
break;
case "fr":
$i18n = array(
"head-title" => "zonesWIFI : Carte des points Wifi gratuits (Données OpenStreetMap)",
"head-description" => "Cette carte localise les Points Wifi gratuits à partir de OpenStreetMap (OSM).",
"osm-attribution" => "© <a href=\'http://www.openstreetmap.org/copyright\'>contributeurs OpenStreetMap</a>",
"Zones Wifi" => "Zones Wifi",
"naviguer" => "
<p>Sur la carte du Sans Fil, les icônes des <em class=\"bleu\">Points Wifi</em> permettent de localiser les zones d'accès gratuit au Wifi. Cliquez sur ces icônes pour afficher la description des lieux.</p>
<p> Recherchez une ville et les donnnées seront extraites pour la zone affichée à l'écran. De là, il est possible de zoomer et voir le détail sur les différents points Wifi.
",
"contribuez" => "
<p>Points Wifi : © Service Overpass,
<a href=\"#\" onclick=\"lien(\"osm_copyright\");return false;\">OpenStreetMap ODbL</a></p>
<p>Localités : Recherche Nominatim, courtoisie de
<a href=\"#\" onclick=\"lien(\"nominatim_mapquest\");return false;\">MapQuest</a>.</p>
",
"points_wifi" => "Points Wifi",
"msg_wifi_point" => " Points Wifi - Zoomez davantage pour localiser ces Points Wifi.",
"msg_search" => "Rechercher ...",
"rechercher" => "Rechercher",
"localiser" => "Où suis-je ?",
"my_location" => "Ma localisation",
"tlocaliser" => "Afficher votre localisation",
"lieu-non-identifie" => "Lieu non identifié"
);
break;
default: ;
}
?>
<!DOCTYPE html>
<html lang="<?php echo $lang;?>">
<head>
<meta charset="utf-8">
<title><?php echo $i18n["head-title"];?></title>
<meta name="viewport" content="width=device-width" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="author" content="Pierre Béland">
<meta name="description" content="<?php echo $i18n["head-description"];?>" />
<meta name="referrer" content="origin">
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="../ol2/OpenLayers.js" type="text/javascript"></script>
<!--
<script src="http://openlayers.org/api/2.13/Geolocation.js"></script>
<script type="application/javascript" src="http://openlayers.org/api/2.13/OpenLayers.mobile.js"></script>
-->
<script type="application/javascript" src="js/fr.js"></script>
<script type="application/javascript" src="OpenStreetMap.js"></script>
<script type="application/javascript" src="overpass.js"></script>
<script type="application/javascript" src="OSMMeta.js"></script>
<script type="application/javascript" src="LoadingPanel.js"></script>
<script type="application/javascript">
//<![CDATA[
var isMobile = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/);
//OpenLayers.ImgPath = "../img/";
// traduction
var lang="<?php echo $lang;?>";
// debug console.log("lang="+lang);
var self="<?php echo $_SERVER['PHP_SELF'];?>";
msg_wifi_point="<?php echo $i18n["msg_wifi_point"];?>";
points_wifi="<?php echo $i18n["points_wifi"];?>";
// debug console.log("debut Js lang="+lang);
var markers = new OpenLayers.Layer.Markers( "Markers" );
var POI = new OpenLayers.Layer.Vector("Loc.");
var geoloc = null;
//var lat = 45.5222;
//var lon = -73.7186;
//var zoom = 10;
// départ - selection wifi pour sherbrooke
//selection_wifi_lonlat(lon=-72.1527,lat=45.3965,zoom=10);
// départ - Geoloc, sinon selection wifi pour quebec
var lon=-71.1598; var lat=46.8226;var zoom=12;var startZoom=zoom;
//getLocation();
// debug console.log("Apres getLocation lat="+lat+" lon="+lon);
var url = window.location.href
// debug console.log("url="+url);
var uri_hash = window.location.hash
// debug console.log("hash="+uri_hash);
var uriHash = uri_hash.replace(/^#/, "") //.split(";");
var debug= "debug, uriHash = " +uriHash;
var kvPair = uriHash.split("/");
if (kvPair.length>2) {
startZoom = kvPair[0];
zoom=startZoom;
lat = kvPair[1];
lon = kvPair[2];
// debug console.log("Uri="+kvPair);
// debug console.log("Init", startZoom, lat, lon);
}
var LonLat = new OpenLayers.LonLat( lon,lat).transform(new OpenLayers.Projection("EPSG:4326"),"EPSG:900913");
var url_lonlat;
var map;
var fenetre_popup;
// controle affichage des marqueurs
// nb dans cercles à partir de zoom=13
var zoom_nb=3;
// icones plus gros et plus clair à partir de zoom=16
var zoom_icone_plus=5;
var wifi_region;
var largeur_popup,hauteur_popup;
// panneau glissant gauche affiché au départ
var showpanel=0;
if (document.body)
{
var largeur_ecran = (document.body.clientWidth);
var hauteur_ecran = (document.body.clientHeight);
}
if (largeur_ecran<=640) {
largeur_popup=250;hauteur_popup=150;
}
else {largeur_popup=300;hauteur_popup=200;
}
function fenetre_popup_info() {
var fenetre_popup=window.open("zoneswifi_info.html",
"pop1","width=200,height=200");
fenetre_popup.document.close();
fenetre_popup.focus();
onblur="window.focus()";
}
function sel_lang (form) {
$lang = form.inputbox.value;
alert ("lang= " + $lang);
}
// apres recherche nominatimm, - demande extraction selon lon,lat,zoom --> bbox calculé
function selection_wifi_lonlat(lon,lat,zoom) {
// debug console.log("sel_wifi lon,lat,zoom "+lon+", "+lat+",",+zoom);
// ferme fenêtre de résultats Nominatim;
cname_result=document.getElementById('result').className
document.getElementById('result').className='hidden';
zoom=zoom-10;if (zoom<0) {zoom=0;}
for (nb in map.layers) {
if (nb > 0) {
// debug console.log("enlève couche wifi précédente, no "+nb);
map.layers[nb].setVisibility(false);
map.removeLayer(map.layers[nb], false);
}
}
var lonlat_reg = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
map.setCenter (lonlat_reg, zoom);
//bounds.left, .bottom, .right, .top
var bounds = new OpenLayers.Bounds();
bounds=map.getExtent();
var WGS84 = new OpenLayers.Projection("EPSG:4326");
bounds.transform(map.getProjectionObject(), WGS84);
var bbox=String(bounds.bottom.toFixed(5)+","+bounds.left.toFixed(5)+","+bounds.top.toFixed(5)+","+bounds.right.toFixed(5));
// debug console.log("bounds "+ bounds+" -> l "+bounds.left+",b "+bounds.bottom+",r "+bounds.right+",t "+bounds.top);
// debug console.log("bbox "+ bbox);
var url1="http://overpass-api.de/api/interpreter?data=[timeout:30];node[internet_access=wlan](";
var url3=");out+meta;(way[internet_access=wlan](";
var url5=");node(w););out+meta;";
url_lonlat=url1+bbox+url3+bbox+url5;
// debug console.log("url_lonlat "+url_lonlat);
//----------
wifi_layer_request_hotspots (couche=wifi_region,
desc="Points Wifi", url=url_lonlat, affichage=true);
}
function lien(nom) {
var url ="Erreur - fonction lien";
if (nom=="osm") {
url="http://www.openstreetmap.org/?lat="+lat+"&lon="+lon+"&zoom="+zoom;}
else if (nom=="osm_copyright") {
url="http://www.openstreetmap.org/copyright";}
else if (nom=="nominatim_mapquest") {
url="http://www.mapquest.com";}
window.open(url," ","left=20;width=90%;height=90%");
}
function afficher_contribuez() {
var contribuez=document.getElementById("contribuez");
// debug console.log("contribuez="+contribuez.className);
if (contribuez.className=="hidden") {contribuez.className="cadre l100";}
else {contribuez.className="hidden";}
// debug console.log("contribuez=>"+contribuez.className);
}
function icone(feature,nb) {
img="img/wifi_bleu.png";
// img pour operateurs ile-sans-fil,zap,etc.
wifi_operator=getAttrib(feature.cluster[nb].attributes,"internet_access:operator").toLowerCase();
wifi_operator=wifi_operator.replace(/î/gi, "i");
wifi_operator=wifi_operator.replace(/é/gi, "e");
wifi_operator=wifi_operator.replace(/-/g, " ");
if (wifi_operator == "ile sans fil")
{img="img/wifi_ilesansfil.png";}
else if (wifi_operator.indexOf("zap") ==0) {
img="img/wifi_zap.png";
}
// // debug console.log(wifi_operator+' img='+img)
return img;
}
var style_wifi_couche = new OpenLayers.Style({
pointRadius: "${radius}",
label:" ${nombre}",
fontColor: "${couleur}",
fontSize: "${police}",
fillColor: "# 033FF",
fillOpacity: "${fillOpacity}",
strokeColor: "#330099",
strokeWidth: "${strokeWidth}",
strokeOpacity: 1,
externalGraphic: "${externalGraphic}",
graphicWidth: "${graphicWidth}"
},
{
context: {
externalGraphic: function(feature) {
zoom=map.getZoom();
// debug console.log("img zoom="+zoom+" zoom_nb="+zoom_nb);
if (feature.attributes.count==1 &&zoom>=zoom_nb) {
for (elem in feature.attributes)
// debug console.log("externalgraphiq attrib elem="+elem);
//for (elem in feature) console.log("externalgraphiq feature elem="+elem);
//console.log("externalgraphiq attributes ="+feature.attributes);
//// debug console.log("externalgraphiq layer ="+feature.layer);
//// debug console.log("externalgraphiq lonlat ="+feature.lonlat);
//// debug console.log("externalgraphiq data ="+feature.data);
//// debug console.log("externalgraphiq geometry ="+feature.geometry);
img=icone(feature,0);
//if (zoom>zoom_icone_plus && img=="img/wifi_bleu.png") {img="img/wifi_bleu_48.png";}
}
else {img="";}
// console.log(wifi_operator+' img='+img)
return img;
},
graphicWidth: function(feature) {
zoom=map.getZoom();
//echelle=map.getScale()
//console.log("Dimension graphique zoom="+zoom+" zoom_icone_plus="+zoom_icone_plus);
if (zoom>zoom_icone_plus) {return 48;}
else {return 24;}
},
graphicXOffset: function(feature) {
var XOffset = 7;
var YOffset = -20;
var Resolution = map.getResolution();
XOffset= XOffset * Resolution / map.getResolution();
// debug console.log("y zoom="+zoom+" XOffset="+XOffset);
return XOffset
},
graphicYOffset: function(feature) {
var XOffset = 7;
var YOffset = -20;
var Resolution = map.getResolution();
YOffset= YOffset * Resolution / map.getResolution();
// debug console.log("y zoom="+zoom+" YOffset="+YOffset);
return YOffset
},
fillOpacity: function(feature) {
zoom=map.getZoom();
if (feature.attributes.count==1 &&zoom>=zoom_nb) {
//console.log("fill zoom="+zoom);
if (zoom>zoom_icone_plus) {return 0.8;}
else {return 1;}
}
else {return 0.3;}
},
radius: function(feature) {
zoom=map.getZoom();
nb=Math.floor(feature.attributes.count*2/5);
rayon=Math.min(nb, 12 )+10;
if (zoom<zoom_nb) {rayon=rayon/1.2}
else if (zoom<zoom_icone_plus) {rayon=rayon/1.1}
return rayon;
},
strokeWidth: function(feature) {
zoom=map.getZoom();
if (zoom<zoom_nb) {return 1;}
else {return 2;}
},
nombre: function(feature) {
zoom=map.getZoom();
var nb=feature.attributes.count;
//blanc=String.fromCharCode("\\u00A0");
blanc=".";
if (nb==1 || zoom<zoom_nb) {return blanc;}
else {return nb;}
},
couleur: function(feature) {
zoom=map.getZoom();
var nb=feature.attributes.count;
if (nb==1 || zoom<zoom_nb) {return "blue";}
else {return "navy";}
},
police: function(feature) {
zoom=map.getZoom();
var nb=feature.attributes.count;
if (nb==1 || zoom<zoom_nb) {return "1px";}
else {return "1em";}
}
}
});
var styleMap_wifi_couche = new OpenLayers.StyleMap({
"default": style_wifi_couche,
"select": {
fillColor: "#8aeeef",
strokeColor: "#32a8a9",
fillOpacity: 0.6
}
});
var texte,operator,building,amenity,shop,leisure,tourism,cuisine,adresse,
addr_no, addr_address,addr_city,addr_suburb,addr_postcode,tel,
wifi_operator,wifi_ssid;
var selectedfeature,
popup,
field;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
function getAttrib(variable,cle) {
if (variable.hasOwnProperty(cle)) {
valeur=variable[cle];
}
else {
valeur="";
}
return valeur;
}
function onLoadEnd () {
// debug console.log("Points Wifi, Download complete");
InfoLoadingPanel.deactivate();
InfoLoadingPanel.destroy();
}
function featureHighlighted(evt) {
var feature = evt.feature;
nb_objets=feature.cluster.length
if (nb_objets>1) {
texte = "<div>"+nb_objets+" Points Wifi</div>";
}
else {
name=getAttrib(feature.cluster[0].attributes,"name");
texte=name;
}
// debug console.log("highlight texte="+texte);
hover = new OpenLayers.Popup.FramedCloud("Popup",
new OpenLayers.LonLat(5.6, 50.6),
null,
"<div>"+texte+"</div>",
null,
false);
//map.addPopup(hover);
}
function featureunhighlighted(evt) {
hover.hide();
}
// Usefull for interaction - not to visualize data
function onPopupClose(evt) {
// 'this' is the popup.
var feature = this.feature;
if (feature.layer) { // Cet objet n'est pas détruit
selector.unselect(feature);
} else { // After "moveend" or "refresh" events on POIs layer all
// features have been destroyed by the Strategy.BBOX
this.destroy();
}
}
function onFeatureUnselect(evt) {
var feature = evt.feature;
if (feature.popup) {
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
}
function onFeatureSelect(event) {
feature=event.feature;
selectedfeature = feature;
attribs="Attribs";
for (var cl in feature.cluster) {
for (var cle in feature.cluster[cl].attributes) {
attribs+="<br/>"+ cle + "="+feature.cluster[cl].attributes[cle];
}
}
nb_objets=feature.cluster.length
if (nb_objets>1) {
texte = "<div>"+nb_objets+ msg_wifi_point+"</div><div class=\"lieu\">";
titre = +nb_objets+" msg_wifi_point";
}
else {texte="";titre=points_wifi;}
for (var nb = 0; nb < nb_objets; nb++) {
img=icone(feature,nb);
name=getAttrib(feature.cluster[nb].attributes,"name");
highway=getAttrib(feature.cluster[nb].attributes,"highway");
operator=getAttrib(feature.cluster[nb].attributes,"operator");
amenity=getAttrib(feature.cluster[nb].attributes,"amenity");
building=getAttrib(feature.cluster[nb].attributes,"building");
shop=getAttrib(feature.cluster[nb].attributes,"shop");
leisure=getAttrib(feature.cluster[nb].attributes,"leisure");
tourism=getAttrib(feature.cluster[nb].attributes,"tourism");
cuisine=getAttrib(feature.cluster[nb].attributes,"cuisine");
tel=getAttrib(feature.cluster[nb].attributes,"phone");
wifi_operator=getAttrib(feature.cluster[nb].attributes,"internet_access:operator");
wifi_ssid=getAttrib(feature.cluster[nb].attributes,"internet_access:ssid");
addr_no=getAttrib(feature.cluster[nb].attributes,"addr:housenumber");
addr_street=getAttrib(feature.cluster[nb].attributes,"addr:street");
addr_city=getAttrib(feature.cluster[nb].attributes,"addr:city");
addr_suburb=getAttrib(feature.cluster[nb].attributes,"addr:suburb");
addr_postcode=getAttrib(feature.cluster[nb].attributes,"addr:postcode");
if (name=="") {
if (operator!="") {
name=operator;
}
else {name="<?php echo $i18n["lieu-non-identifie"];?>
";}
}
if (lang=="fr")
{
if (amenity!="") {
if (amenity.toLowerCase()=="library") {amenity="Bibliothèque";}
else if (amenity.toLowerCase()=="townhall") {amenity="Hotel de ville";}
else if (amenity.toLowerCase()=="community_centre") {amenity="Centre communautaire";}
else if (amenity.toLowerCase()=="social_centre") {amenity="Centre de services sociaux";}
else if (amenity.toLowerCase()=="cafe") {amenity="Café";}
else if (amenity.toLowerCase()=="place_of_worship") {amenity="Lieux de culte";}
else if (amenity.toLowerCase()=="hospital") {amenity="Hopital";}
else if (amenity.toLowerCase()=="pharmacy") {amenity="Pharmacie";}
else if (amenity.toLowerCase()=="clinic") {amenity="Clinique médicale";}
else if (amenity.toLowerCase()=="doctors") {amenity="Médecins";}
else if (amenity.toLowerCase()=="post_office") {amenity="Poste";}
else if (amenity.toLowerCase()=="marina") {amenity="Marina";}
else if (amenity.toLowerCase()=="fast_food") {amenity="Resto Rapide";}
else if (amenity.toLowerCase()=="ice_cream") {amenity="Crème Glacée";}
}
if (shop!="") {
if (shop.toLowerCase()=="supermarket") {shop="Supermarché";}
else if (shop.toLowerCase()=="mall") {shop="Centre commercial";}
else if (shop.toLowerCase()=="department_store") {shop="Magasin";}
else if (shop.toLowerCase()=="clothes") {shop="Vêtements";}
else if (shop.toLowerCase()=="stationery") {shop="Articles de bureau";}
else if (shop.toLowerCase()=="bakery") {shop="Boulangerie";}
}
if (leisure!="") {
if (leisure.toLowerCase()=="park") {leisure="Parc";}
else if (leisure.toLowerCase()=="sports_centre") {leisure="Centre sportif";}
else if (leisure.toLowerCase()=="marina") {leisure="Marina";}
else if (leisure.toLowerCase()=="cinema") {leisure="Cinéma";}
}
if (tourism!="") {
if (tourism.toLowerCase()=="camp_site") {tourism="Camping";}
else if (tourism.toLowerCase()=="hotel") {tourism="Hotel";}
else if (tourism.toLowerCase()=="hostel") {tourism="Auberge";}
else if (tourism.toLowerCase()=="guest_house") {tourism="Chambre d'hôte";}
}
if (highway!="") {
if (highway.toLowerCase()=="rest_area") {highway="Halte routière";}
}
if (building!="") {
if (building.toLowerCase()=="hospital") {building="Hopital";}
else if (building.toLowerCase()=="school") {building="École";}
else if (building.toLowerCase()=="public_building") {amenity="Immeuble public";}
}
if (cuisine!="") {
// trad
}
}
if (tel!="") {
if (tel.indexOf("+")<0) {tel="+"+tel;}
}
type_osm="";
if (amenity!="") {
type_osm=amenity
}
else if (shop!="") {
type_osm=shop;
}
else if (leisure!="") {
type_osm=leisure;
}
else if (tourism!="") {
type_osm=tourism;
}
else if (highway!="") {
type_osm=highway;
}
else if (building!="yes") {
type_osm=building;
}
adresse="";
if (addr_no != "") {adresse+=addr_no +", ";}
if (addr_street != "") {adresse+=addr_street;}
if (addr_suburb != "") {adresse+="<br/>"+addr_suburb;}
if (addr_city != "") {adresse+="<br/>"+addr_city;}
if (addr_postcode != "") {adresse+=" "+addr_postcode;}
if (tel != "") {adresse+="<br/>"+tel;}
wifi="";
if (wifi_operator != "") {wifi+="<em>Opérateur Wifi</em>: "+wifi_operator+"<br/>";}
if (wifi_ssid != "") {wifi+="SSID: "+wifi_ssid;}
if (wifi!="") {wifi="<div>"+wifi+"</div>";}
if (nb_objets>5) {
if (nb<16) {texte += "<h3 class=\"popup2\">"+name+" <em>"+type_osm+"</em></h3>";}
else if (nb==16) {texte+="<h3 class=\"popup\"> ... </h3>"}
}
else {
texte += "<div class=\"lieu\">\n<img class=\"gauche\" src=\""+img+"\"/> <h3 class=\"popup\">"+name+"<br/><br/></h3><div class=\"sautgauche\">"+type_osm+"</div>";
texte+="<div>"+adresse+"</div><div class=\"wifi\">"+wifi+"</div>\n</div>\n";
}
// console.log("texte "+texte);
}
if (nb_objets>1) {
texte +="</div>\n";
titre = nb_objets+msg_wifi_point;
}
// console.log("texte "+texte);
popup = new OpenLayers.Popup.FramedCloud(
"wifiPopup",
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(largeur_popup,hauteur_popup),
texte,
null,
true,onPopupClose
);
feature.popup = popup;
popup.feature = feature;
popup.autoSize = false;
map.addPopup(popup, true);
}
function wifi_layer_request_hotspots (couche,desc,url_couche,affichage) {
// url - Overpass-API Service, dynamic query to base OSM
// debug console.log("fonction wifi_layer_request_hotspots desc="+desc+", url_couche="+url_couche);
couche = new OpenLayers.Layer.Vector(desc, {
strategies: [new OpenLayers.Strategy.Fixed(), new OpenLayers.Strategy.Cluster() /*,new OpenLayers.Strategy.BBOX({resFactor: 1.1})*/ ],
styleMap: styleMap_wifi_couche,
protocol: new OpenLayers.Protocol.HTTP({
url: url_couche,
format: new OpenLayers.Format.OSMMeta()
}),
forceFixedZoomLevel: true, numZoomLevels: null, MinZoom: 10, MaxZoom: 17,
projection: new OpenLayers.Projection("EPSG:4326")
});
couche.visibility= true;
map.addLayer(couche);
// debug console.log("fonction wifi_layer_request_hotspots - couche wifi ajoutée");
//controls
selector = new OpenLayers.Control.SelectFeature(couche);
map.addControl(selector);
selector.activate();
couche.events.on({
"featureselected": onFeatureSelect,
"featureunselected": onFeatureUnselect,
"loadend": onLoadEnd
});
var highlightCtrl = new OpenLayers.Control.SelectFeature(couche, {
hover: true,
highlightOnly: true,
renderIntent: "temporary",
eventListeners: {
featurehighlighted: featureHighlighted,
featureunhighlighted: featureunhighlighted
}
});
}
function req_localiser () {
// Recenter on user position
navigator.geolocation.getCurrentPosition(function(position) {
// document.getElementById('info').innerHTML
// = " Latitude: " +
// position.coords.latitude +
// " Longitude: " +
// position.coords.longitude;
lat=position.coords.latitude;
lon=position.coords.longitude;
if (zoom<10) {zoom=zoom+10;}
if (zoom<12) {zoom=12;}
if (zoom>17) {zoom=17;}
console.log("Geoloc Latitude: " +
position.coords.latitude +
" Longitude: " +
position.coords.longitude);
lonLat = new OpenLayers.LonLat(position.coords.longitude,
position.coords.latitude)
.transform(
new OpenLayers.Projection("EPSG:4326"), //transform from WGS 1984
map.getProjectionObject() //to Spherical Mercator Projection
);
// map.setCenter(lonLat, zoom);
var loc_feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point( lon, lat ).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()),
{description:"<?php echo $i18n['my_location'];?>"} ,
{externalGraphic: '../ol2/img/marker.png', graphicHeight: 25, graphicWidth: 21, graphicXOffset:-12, graphicYOffset:-25 }
);
selection_wifi_lonlat(lon=lon,lat=lat,zoom=zoom);
POI = new OpenLayers.Layer.Vector("Loc.");
POI.addFeatures(loc_feature);
map.addLayer(POI);
});
}
function init_map(){
var options = {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
numZoomLevels: 20,
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.ZoomPanel(),
new OpenLayers.Control.ZoomIn(),
new OpenLayers.Control.ZoomOut(),
new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.KeyboardDefaults(),
new OpenLayers.Control.Attribution({
div: document.getElementById('map_attribution') }),
new OpenLayers.Control.Scale()
]
};
OpenLayers.Lang.setCode("<?php echo $lang;?>");
OpenLayers.ProxyHost = "proxy-overpass.php?url=";
map = new OpenLayers.Map({
div:"map",
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
numZoomLevels: 20,
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.ZoomIn(),
new OpenLayers.Control.ZoomOut(),
new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.KeyboardDefaults(),
new OpenLayers.Control.Attribution({
div: document.getElementById('map_attribution') }),
new OpenLayers.Control.Scale()
]
} );
map.numZoomLevels = null;
layerMapnik = new OpenLayers.Layer.OSM.Mapnik("OpenStreetMap",
{attribution: "<?php echo $i18n["osm-attribution"];?>",
zoomOffset:10,
minZoomLevel: 10,
resolutions: [152.87405654907226, 76.4370282714844,38.2185141357422,19.1092570678711,9.55462853393555,4.77731426696777,2.38865713348389,1.19432856674194]
});
map.addLayer(layerMapnik);
InfoLoadingPanel=new OpenLayers.Control.LoadingPanel();
map.addControl(InfoLoadingPanel);
// gold();
map.addLayer(markers);
var lonLat;
// Minimize server request - minimum zoom at 12
if (zoom<12) {zoom=12;}
selection_wifi_lonlat(lon=lon,lat=lat,zoom=zoom);
function handleZoom(event) {
var map = event.object;
resolution=map.getResolution();
echelle=map.getScale();
minzoom=map.getMinZoom();
// debug console.log("movestart zoom="+map.getZoom()+" resolution="+resolution+" echelle="+echelle+" minzoom="+minzoom)
if (map.getZoom() < 11) {
OpenLayers.Event.stop(event);
}
}
var updateUrlHash = function () {
//this is bound to the map, so:
//var zoom = this.getZoom();
var zoom = map.getZoom();
zoom=zoom+10;
//zoomChanged();
// debug console.log("upU zoom", zoom);
var lonLat = this.getCenter().transform("EPSG:900913", "EPSG:4326")
var lat=lonLat.lat.toFixed(6);
var lon=lonLat.lon.toFixed(6);
window.location.hash = zoom + '/' + lat + '/' + lon;
}
var zoomChanged = function ()
{
var zoom = map.getZoom();
// debug console.log("zoomChanged", zoom);
}
//register the moveend event on the map (also catches zoomend)
map.events.register('moveend', map, updateUrlHash);
map.events.register("zoomend", map, zoomChanged);
map.events.register('movestart', map, handleZoom)
} // fin init_map
// ************ NOMINATIM change your country code for language localisation
// var lang="ar" , "en" or "fr" modified by html language selection button;
var lang="<?php echo $lang;?>";
/*========================================================================
NOMINATIM SEARCH functions
source of functions http://wiki.openstreetmap.org/wiki/User:SunCobalt/OpenLayers_Suche
========================================================================
*/
function fragmapquest(){
// ************ change your country code for language localisation
// var lang="ar" , "en" or "fr" modified by html language selection button;
var urlnominatim="http://nominatim.openstreetmap.org/search.php";
var urlmapquest="http://pierzen.dev.openstreetmap.org/hot/openlayers/nominatim/mapquestjs.php";
search_query=document.getElementById("nominatim_query").value;
exclude_place_ids="state,region,administrative";
url=urlmapquest+"?q="+search_query+"&limit=8"+"&lang="+lang;
// debug console.log("Nominatim, url="+url);
var http = new XMLHttpRequest();
http.open("GET",url,false);
http.send(null);
nominatim_line=http.responseText.split("\n");
resultdiv = document.getElementById("result");
resultdiv.className="displayblock";
if (lang=="fr")
{
i18n_info_enter_locality_above="Spécifiez une localité ci-dessus, et appuyez sur le bouton Rechercher.";
i18n_info_no_search_results_for="Aucun résultat pour";
i18n_info_search_results_for="Résultats de recherche pour";
}
else
{
i18n_info_enter_locality_above="Spécify a locality above and click on the Search button.";
i18n_info_no_search_results_for="No result for ";
i18n_info_search_results_for="Search results for ";
}
result_close="<a id='result_close' class='right_panel' href='#' onclick=\"document.getElementById('result').className='hidden';\" title='Fermer le panneau des Résultats'><button class='btn small'><img src='img/close.png' class='right_panel' /></button></a><br />";
resultdiv.innerHTML=result_close+resultdiv.innerHTML;
if (search_query.length==0) {
msg_search_results=i18n_info_enter_locality_above;
resultdiv.innerHTML=result_close+msg_search_results;
}
else {
msg_search_results=i18n_info_no_search_results_for+" \""+search_query+"\"<br /><ul>";
if(nominatim_line.length<=3){
resultdiv.innerHTML="<br />"+msg_search_results+" \""+search_query+"\"";
resultdiv.innerHTML=result_close+resultdiv.innerHTML;
}else{
search_results_for=i18n_info_search_results_for;
resultdiv.innerHTML=search_results_for +" \""+search_query+"\"";
i=0;
for(i=0;i<nominatim_line.length;i++){
nominatim_col=nominatim_line[i].split("\t");
for (col in nominatim_col) {
console.log("Nominatim col "+col + ", " +nominatim_col[col]);
}
if((nominatim_col[0]*nominatim_col[0]>0)||(nominatim_col[1]*nominatim_col[1]>0)){
if(i==0){selection_wifi_lonlat(nominatim_col[0],nominatim_col[1]),11;}
displaytext=nominatim_col[2];
resultdiv.innerHTML=resultdiv.innerHTML+"<font size=2><li><a href=# onmouseup=\"selection_wifi_lonlat("+nominatim_col[0]+","+nominatim_col[1]+",11);\" onclick='//vectorLayer.visibility=false;'>"+displaytext+"</a></li><br>";
}
}
resultdiv.innerHTML=resultdiv.innerHTML+"</ul>";
resultdiv.innerHTML=result_close+resultdiv.innerHTML;
}
}
return false;
}
/*========================================================================
NOMINATIM SEARCH functions end
========================================================================*/
//]]>
</script>
<link rel="stylesheet" href="../ol2/theme/default/style.css" type="text/css">
<style type="text/css">
html, body {
width:100%; height: 100%;
}
body {
margin: 0.1em;
padding: 0;
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size:<?php echo $wordsize;?>;
}
header {width:100%; height:6%; line-height:5%;padding-top:0.6%;
font-family:"Comic Sans MS", Times, serif; color:beige;
background-color: #202080;
}
#sect2 {float:left;margin-righ:2em; line-height:100%; color:white; font-size: 1em; padding-left:0.5em; clear:right;}
div.olPopupCloseBox
{
background-image: url("img/close.png");
background-color: rgba(255, 0, 255, 0.4);
}
.l25{
width : 24.9%;
}
.l75{
width : 74.9%;
}
.l90{
width:90%;
margin:0.5em;
}
.l100{
width:99%;
}
.hidden{
display:none;
}
#section_info {
font-size:85%;
position:absolute; left:+5%; top:+15%; width:55%;
z-index:2;
}
#section_principale {
float: right;
clear: right;
z-index:0;
}
#map {
width:100%;height:90%;
clear:both; overflow:hidden;
background-color:#3F99AA;
}
#legende {
width : 40%;
float: left;
background-color:#EEEAEE;
}
#legende img {
height:22px;
}
#naviguer {
clear:right;
}
a.blanc
{ height:100%; color:#eaeade; text-decoration:none; font-size:0.8em;
}
footer {
bottom: 0;
width:100%; height: 5%;
background-color: #202080;
color:white;
font-family: Verdana;
font-size: 95%;
display: block;
}