1
|
var map;
|
2
|
var startX = 49.7248;
|
3
|
var startY = 13.3521;
|
4
|
var startZoom = 17;
|
5
|
|
6
|
var currentTime = 0;
|
7
|
|
8
|
|
9
|
function initMap() {
|
10
|
map = L.map('heatmap').setView([startX, startY], startZoom);
|
11
|
|
12
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
13
|
attribution: '',
|
14
|
maxZoom: 19
|
15
|
}).addTo(map);
|
16
|
}
|
17
|
|
18
|
|
19
|
function setMapView(latitude = startX, longitude = startY, zoom = startZoom) {
|
20
|
map.setView([latitude, longitude], zoom);
|
21
|
}
|
22
|
|
23
|
|
24
|
function changeTime(direction, max = 0) {
|
25
|
let time = document.getElementById('time');
|
26
|
|
27
|
if (direction === 'next') {
|
28
|
currentTime += 1;
|
29
|
|
30
|
if (currentTime > 23) {
|
31
|
currentTime = 0;
|
32
|
}
|
33
|
}
|
34
|
else if (direction === 'prev') {
|
35
|
currentTime -= 1;
|
36
|
|
37
|
if (currentTime < 0) {
|
38
|
currentTime = 23;
|
39
|
}
|
40
|
}
|
41
|
|
42
|
time.textContent = currentTime + ":00";
|
43
|
time.className = 'time hour-' + currentTime;
|
44
|
}
|
45
|
|
46
|
|
47
|
function animateTimeline() {
|
48
|
setTimeout(
|
49
|
function () {
|
50
|
if (currentTime < 23) {
|
51
|
animateTimeline();
|
52
|
changeTime('next');
|
53
|
}
|
54
|
else {
|
55
|
changeTime('next');
|
56
|
}
|
57
|
}, 400);
|
58
|
}
|
59
|
|
60
|
|
61
|
function showHeatmap(route) {
|
62
|
$.ajax({
|
63
|
type: "POST",
|
64
|
url: route,
|
65
|
success: function(result) {
|
66
|
drawHeatmap(result);
|
67
|
}
|
68
|
});
|
69
|
}
|
70
|
|
71
|
|
72
|
function drawHeatmap(points) {
|
73
|
points = points.map(function (p) { return [p['y'], p['x'], p['number']]; });
|
74
|
|
75
|
L.heatLayer(points).addTo(map), draw = true;
|
76
|
}
|