-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
236 lines (194 loc) · 7.39 KB
/
index.html
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
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,userscalable=no">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/font-awesome.min.css">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==" crossorigin=""/>
<link rel="stylesheet" href="leaflet.photon-0.8.0/leaflet.photon.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous" ></script>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA==" crossorigin="" ></script>
<script src="leaflet.photon-0.8.0/leaflet.photon.js" ></script>
<style>
body
{
background:black;
font-family:"Lucida Sans";
}
#mapid
{
position:fixed;
bottom:0;
left:0;
right:0;
top:10em;
}
h1
{
color: white;
}
.leaflet-popup-content
{
font-size: 150%;
}
.photon-input
{
font-size: 200%;
/*max-width:250px;*/
}
a
{
text-decoration:none;
color:white
}
a:hover
{
color:yellow
}
.my-div-icon
{
background: rgba(255,255,255,.90);
padding: 2px 0 5px 0;
width: 50px!important;
margin-top: 20px!important;
margin-left: -25px!important;
text-align: center;
border-radius: 5px;
border: 1px solid black;
}
.my-logo-icon-bold
{
color: darkblue;
text-align: center;
text-shadow: -2px 0 white, 0 2px white, 2px 0 white, 0 -2px white;
width: 250px!important;
margin-top: -20px!important;
margin-left: -125px!important;
}
</style>
</head>
<body>
<div id='header'>
<h1><span style='color:orange'>PROBABLE AED <span id="timespan">2</span> MINUTES MAP.</span> <span style='float:right'>👉 HELP MAPPING: <a href='mailto:[email protected]?subject=AED suggestion&body=I found an AED at this location:'>✉</a> | <a target='_blank' href='https://www.openstreetmap.org'>WEB</a> | <a target='_blank' href='https://play.google.com/store/apps/details?id=io.mapsquare.osmcontributor&hl=fr'>APP</a> <i id='spin' style='display:none' class='fa fa-spin fa-spinner'></i></span></h1>
<div style='font-size:small;color:white;margin-top:-.75em;margin-bottom:.5em'><i><span>DEMO NOT FOR REAL USE - data coming from OSM & Interparking + OSM data for AXA & ING banks</span><span style='float:right'>Take also a look at an app such as <a href='https://aedmap.org/fr/protection-civile-bons-samaritains/'><b>AED-MAP</b></a></span></i></div>
</div>
<div id="mapid"></div>
</body>
<script>
$('#mapid').css('top', $('#header').height()+10);
// initializes map
var mymap = L.map('mapid', { zoomControl: false }).setView([50.84, 4.36], 13);
mymap.locate({setView : true});
var data = null;
var tL = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
attribution: 'Map data © <a target="_blank" href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a target="_blank" href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>.<br><!--2010 Population density: http://sedac.ciesin.columbia.edu/maps/services-->Interparking (lic?), Basic-FIT (lic?)<br>Adress search: <a target="_blank" href="https://github.com/komoot/leaflet.photon">Leaflet Photon</a> under <a target="_blank" href="https://github.com/komoot/leaflet.photon/blob/master/LICENSE">Apache 2.0 Licence</a>',
maxZoom: 18,
zoom: 12
}).addTo(mymap);
/*L.tileLayer('https://cartocdn-gusc.global.ssl.fastly.net/duncansmith/api/v1/map/6448b3e05b1f0afbd28f9a9ed45019fc:1523283294850/0,1,2/{z}/{x}/{y}.png',
{
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>.<br>Population density: http://sedac.ciesin.columbia.edu/maps/services',
maxZoom: 18,
zoom: 12
}).addTo(mymap);*/
//var wmsLayer = L.tileLayer.wms('http://sedac.ciesin.columbia.edu/geoserver/wms?', {layers:'gpw-v3:gpw-v3-population-density_2000', opacity :.25, attribution:'r'}).addTo(mymap);
L.control.zoom({ position:'topright' }).addTo(mymap)
L.control.scale().addTo(mymap);
var fG = L.featureGroup(),
fH = L.featureGroup(),
fI = L.featureGroup()
L.control.layers({'OSM':tL}, {'2 minutes-areas':fG, 'locations':fH, 'names':fI}).addTo(mymap);
var photonControlOptions=
{
onSelected: photonHandler,
placeholder: 'adress',
position: 'topleft'
}
function photonHandler(e)
{
var coords = e.geometry.coordinates;
L.circleMarker([coords[1], coords[0]], {radius:20, color:'red', fillColor:'red', weight:8}).addTo(mymap)
// data : look for the nearest
var candidates = [ [coords[1], coords[0]] ]
for (var i=0; i<data.length; ++i)
{
if (data[i] == null) continue;
if (data[i].type !== 'node') continue;
if ( (data[i].lat == null) | (data[i].lon == null ) ) continue;
//console.log(data[i], [coords[1], coords[0]], [data[i].lat, data[i].lon]);
var d = mymap.distance([coords[1], coords[0]], [data[i].lat, data[i].lon]);
if (d < 500)
{
candidates.push(data[i]);
L.circleMarker([data[i].lat, data[i].lon], {radius:20, color:'green', fill:false, weight:8}).addTo(mymap)
var myIcon = L.divIcon({className: 'my-div-icon', html:Math.round(d) + ' m'});
L.marker([data[i].lat, data[i].lon], {icon: myIcon}).addTo(mymap);
}
}
console.log(candidates)
if (candidates.length > 1)
{
console.log('e')
mymap.flyToBounds(L.polygon(candidates).getBounds())
/*for (var i=0; i<candidates.length; ++i)
{
// routing -> calculer le + proche
// mais plus compliqué que ça, car un DEA un peu plus loin, mais failement accessible sera mieux qu'un plus proche mis compliqué à trouver
}*/
}
else
{
mymap.flyTo([coords[1], coords[0]], 15);
}
mymap.removeLayer(fG)
}
L.control.photon(photonControlOptions).addTo(mymap);
// style for the isochrones
var myStyle = {
"color": "#00BB00",
"weight": 2,
"fillOpacity": 0.2
};
// get the AED data
$('#spin').fadeIn()
$.get('get_data.php?a='+Math.random(),
function(e)
{
$('#spin').fadeOut()
data = e.elements
var isolines = e.areas
// renders the AED data
for (var i=0; i<data.length; ++i)
{
if ( (data[i].lat == null) | (data[i].lon == null ) )
{
continue;
}
fG.addLayer(L.geoJSON(isolines[i], {style: myStyle})) // isochrone
var popup_content = ''
for (tag in data[i].tags)
{
if (!data[i].tags.hasOwnProperty(tag)) continue;
popup_content += '<b>' + escape(tag) + '</b>:' + escape(data[i].tags[tag]).replace(/%20/g,' ') + '<br>'
}
fH.addLayer(L.circleMarker([data[i].lat, data[i].lon], {radius:3,color:'red',fillColor:'red',opacity:1}).bindPopup(popup_content))
if (data[i].tags != null)
{
var operator = data[i].tags.operator
if (operator != null) if (operator.trim() != '')
{
var myIcon = L.divIcon({className: 'my-logo-icon-bold', html:operator});
fI.addLayer(L.marker([data[i].lat, data[i].lon], {icon: myIcon}).bindPopup(popup_content))
}
}
}
fG.addTo(mymap);
fH.addTo(mymap);
fI.addTo(mymap);
}, 'json')
// then...
// do not use the OSM community server
// keep it simple...
// ...
</script>
</html>