1 |
3fc08f2d
|
vastja
|
var mymap;
|
2 |
|
|
|
3 |
|
|
|
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 |
|
|
|
14 |
|
|
|
15 |
|
|
}
|
16 |
|
|
|
17 |
|
|
function showHeatmap(route) {
|
18 |
|
|
|
19 |
|
|
$.ajax({
|
20 |
|
|
type: "POST",
|
21 |
|
|
url: route,
|
22 |
|
|
success: function(result) {
|
23 |
|
|
drawHeatmap(result);
|
24 |
|
|
}
|
25 |
|
|
});
|
26 |
|
|
|
27 |
|
|
}
|
28 |
|
|
|
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 |
|
|
|