Revize c236b33a
Přidáno uživatelem Martin Šebela před asi 4 roky(ů)
website/public/js/zcu-heatmap.js | ||
---|---|---|
1 | 1 |
var mymap; |
2 |
var startX = 49.7248; |
|
3 |
var startY = 13.3521; |
|
4 |
var startZoom = 17; |
|
2 | 5 |
|
6 |
function initMap() { |
|
7 |
mymap = L.map('heatmap').setView([startX, startY], startZoom); |
|
3 | 8 |
|
4 |
function initMap(x = 49.724, y = 13.352, zoom = 17) { |
|
5 |
|
|
6 |
mymap = L.map('heatmap').setView([x, y], zoom); |
|
7 |
|
|
8 |
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
|
9 |
attribution: '© <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>', |
|
10 |
maxZoom: 19 |
|
11 |
}).addTo(mymap); |
|
12 |
|
|
13 |
|
|
9 |
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
|
10 |
attribution: '', |
|
11 |
maxZoom: 19 |
|
12 |
}).addTo(mymap); |
|
13 |
} |
|
14 | 14 |
|
15 |
function setMapView(latitude = startX, longitude = startY, zoom = startZoom) { |
|
16 |
mymap.setView([latitude, longitude], zoom); |
|
15 | 17 |
} |
16 | 18 |
|
17 | 19 |
function showHeatmap(route) { |
18 |
|
|
19 |
$.ajax({ |
|
20 |
type: "POST", |
|
21 |
url: route, |
|
22 |
success: function(result) { |
|
23 |
drawHeatmap(result); |
|
24 |
} |
|
25 |
}); |
|
26 |
|
|
20 |
$.ajax({ |
|
21 |
type: "POST", |
|
22 |
url: route, |
|
23 |
success: function(result) { |
|
24 |
drawHeatmap(result); |
|
25 |
} |
|
26 |
}); |
|
27 | 27 |
} |
28 | 28 |
|
29 | 29 |
function drawHeatmap(points) { |
30 |
|
|
31 |
// Flipped x and y |
|
32 |
points = points.map(function (p) { return [p['y'], p['x'], p['number']]; }); |
|
33 |
|
|
34 |
L.heatLayer(points).addTo(mymap), draw = true; |
|
35 |
|
|
36 |
} |
|
37 |
|
|
38 |
|
|
39 |
|
|
30 |
points = points.map(function (p) { return [p['y'], p['x'], p['number']]; }); |
|
40 | 31 |
|
32 |
L.heatLayer(points).addTo(mymap), draw = true; |
|
33 |
} |
Také k dispozici: Unified diff
Feature/7926/gui