-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_border_multiple_layers.html
346 lines (291 loc) · 8.22 KB
/
demo_border_multiple_layers.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
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
<!doctype html>
<html lang="en" class="no-js">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>On Line</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<script src="//apiv3.geoportail.lu/apiv3loader.js" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<meta name="layout" content="main"/>
<style>
#map {
width: 100%;
height: 100%;
/*-webkit-filter: grayscale(100%);
filter: grayscale(100%);
49.711312, 6.109347
*/
}
#topcorner {
position: absolute;
top: 250px;
right: 5%;
z-index: 5;
background-color: rgba(50, 50, 50, 0.5);
color: #ffffff;
text-align: left;
font-family: 'Roboto', 'sans-serif';
padding: 0;
margin: 0;
font-size: 1.5em;
font-weight: bold;
border: 1px solid transparent;
min-width: 120px;
line-height: 1.5em;
}
#lm {
position: absolute;
top: 50px;
right: 5%;
z-index: 5;
background-color: rgba(50, 50, 50, 0.5);
color: #ffffff;
text-align: left;
font-family: 'Arial', 'sans-serif';
padding: 0;
margin: 0;
font-size: 1em;
font-weight: bold;
border: 1px solid transparent;
min-width: 120px;
line-height: 1.5em;
}
#topcorner .row {
margin-top: 0.8vmin;
}
#loading {
background: transparent;
color: #1b6d85;
position: absolute;
top: 50%;
left: 50%;
height: 20px;
width: 100px;
padding: 0;
-ms-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
z-index: 7;
}
</style>
<style>
body {
background-color: #fff;
}
body a {
color: #000;
}
#content {
height: 5px;
margin: 0;
position: absolute;
top: 201px;
z-index: 6;
background-color: rgba(255, 255, 255, 0.9);
}
.row {
position: relative;
max-width: 100%;
margin: 0 auto;
padding: 0 5%;
}
#less {
background-color: rgba(255, 255, 255, 0.9);
}
#more {
background-color: rgba(255, 255, 255, 0.9);
z-index: 2323;
}
.moreless h1 > span {
background-color: rgba(255, 255, 255, 0.9);
}
.moreless h2 > span {
background-color: rgba(255, 255, 255, 0.9);
}
#header {
position: absolute;
top: 0px;
z-index: 2255;
background-color: transparent;
height: 250px;
width: 100%;
text-align: center;
color: black;
padding: 0;
}
#header h1 {
font-size: 3em;
}
#header h2 {
margin-top: 0em;
font-size: 1.5em;
}
#header p {
font-size: 1.1em;
text-align: left;
}
#footer {
/* position: absolute;
bottom: -300px;*/
margin: 0;
z-index: 5;
background-color: rgba(255, 255, 255, 0.5);
width: 100%;
color: #000;
}
#footer .col-sm-4 {
vertical-align: bottom;
display: table-cell;
height: 100%;
}
#footer .col-sm-3 {
vertical-align: bottom;
display: table-cell;
height: 100%;
}
#footer .row {
max-width: 80%;
}
#footer img {
display: table-cell;
max-height: 80px;
max-width: 100%;
vertical-align: bottom
}
.tooltip {
position: relative;
padding: 3px;
background: rgba(0, 0, 0, 0.5);
color: white;
opacity: 0.7;
white-space: nowrap;
font: 10pt sans-serif;
}
</style>
</head>
<body>
<div id="topcorner">
<div class="row">Coordinates:<br>
<div id="coordinates"></div></div>
<div class="row">Time:<br>
<div id="time"></div></div>
<div class="row">Distance:<br>
<div id="distance"></div></div>
</div>
<div id="lm">
</div>
<div id="loading">Loading ..</div>
<div id="map">
<div id="tooltip" class="tooltip"></div>
</div>
<script>
var ajaxStart = function () {
$('#loading').show();
};
var ajaxStop = function () {
$('#loading').hide();
};
var ts = new Date();
var nowPosition;
var markers = {};
var getMarkers = function (noretrigger) {
ajaxStart();
var zoom = map.getView().getZoom();
$.getJSON("./border.json" , function (data) {
ts = new Date();
if (data.length) {
map.showMarker(
{position: [Number(data[0]['lat']), Number(data[0]['lon'])],
positionSrs: 4326,
positioning: 'center-center',
iconURL: 'https://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png',
html: 'Current location'
});
}
var source1 = createLayer('blue');
var source2 = createLayer('#FF00FF');
var source3 = createLayer('#F000FF');
var source4 = createLayer('#49ff00');
var source5 = createLayer('red');
$.each(data, function (x, l) {
var feature = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.transform([Number(l['lat']), Number(l['lon'])], 'EPSG:4326', 'EPSG:3857')),
distance: Number(l['distance_From_Border_Meter'])
});
if (feature.get('distance') < 10) {
source1.addFeature(feature);
} else if (feature.get('distance') < 40) {
source2.addFeature(feature);
} else if (feature.get('distance') < 60) {
source3.addFeature(feature);
} else if (feature.get('distance') < 80) {
source4.addFeature(feature);
} else {
source5.addFeature(feature);
}
});
ajaxStop();
});
};
function displayTooltip(evt) {
var pixel = evt.pixel;
var feature = map.forEachFeatureAtPixel(pixel, function(feature) {
return feature;
});
tooltip.style.display = feature ? '' : 'none';
if (feature) {
overlay.setPosition(evt.coordinate);
tooltip.innerHTML = 'Distance to border: ' + feature.get('distance');
}
};
var map = new lux.Map({
target: 'map',
bgLayer: 'blank',
zoom: 7,
position: [76825, 75133],
layers: [1459,349]
,layerManager: {
target: 'lm'
}
});
var tooltip = document.getElementById('tooltip');
var overlay = new ol.Overlay({
element: tooltip,
offset: [10, 0],
positioning: 'bottom-left'
});
map.addOverlay(overlay);
map.on('pointermove', displayTooltip);
function createLayer(pointColor) {
var imageStyle = new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
snapToPixel: false,
fill: new ol.style.Fill({color: pointColor}),
stroke: new ol.style.Stroke({color: 'white', width: 1})
})
});
var positionSource = new ol.source.Vector({wrapX: false});
var positionLayer = new ol.layer.Vector({
source: positionSource,
style: imageStyle,
map: map
});
//map.addLayer(positionLayer);
return positionSource
}
var position2 = [ 6.367662, 49.460796 ];
map.showMarker(
{position: position2,
positionSrs: 4326,
positioning: 'center-center',
iconURL: 'https://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png',
html: '<h2>The popover</h2><p>With some content</p><ul><li>Item 1</li><li>Item 2</li></ul>'
});
getMarkers();
</script>
</body>
</html>