Projekt

Obecné

Profil

Stáhnout (2.14 KB) Statistiky
| Větev: | Revize:
1
var map;
2
var heatmapLayer = null;
3

    
4
var startX = 49.7248;
5
var startY = 13.3521;
6
var startZoom = 17;
7

    
8
var currentTime = 0;
9

    
10

    
11
function initMap() {
12
  map = L.map('heatmap').setView([startX, startY], startZoom);
13

    
14
  L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
15
    attribution: '',
16
    maxZoom: 19
17
  }).addTo(map);
18
}
19

    
20

    
21
function setMapView(latitude = startX, longitude = startY, zoom = startZoom) {
22
  map.setView([latitude, longitude], zoom);
23
}
24

    
25

    
26
function changeTime(direction, max = 0) {
27
  let time = document.getElementById('time');
28

    
29
  if (direction === 'next') {
30
    currentTime += 1;
31

    
32
    if (currentTime > 23) {
33
      currentTime = 0;
34
    }
35
  }
36
  else if (direction === 'prev') {
37
    currentTime -= 1;
38

    
39
    if (currentTime < 0) {
40
      currentTime = 23;
41
    }
42
  }
43

    
44
  time.textContent = currentTime + ":00";
45
  time.className = 'time hour-' + currentTime;
46
}
47

    
48

    
49
function animateTimeline() {
50
  setTimeout(
51
    function () {
52
      if (currentTime < 23) {
53
        animateTimeline();
54
        changeTime('next');
55
      }
56
      else {
57
        changeTime('next');
58
      }
59
    }, 400);
60
}
61

    
62
function showHeatmap(route, date) {
63

    
64
  $.ajax({
65
    type: "POST",
66
    url: route + date,
67
    success: function(result) {
68
      drawHeatmap(result);
69
    }
70
  });
71
}
72

    
73

    
74
function drawHeatmap(points) {
75

    
76
  // Todo still switched
77
  points = points.map(function (p) { return [p['y'], p['x'], p['number']]; });
78
  if (heatmapLayer != null) {
79
    mymap.removeLayer(heatmapLayer);
80
  }
81
  heatmapLayer = L.heatLayer(points).addTo(mymap), draw = true; 
82
  // var heat_01 = ...
83
  // on background map.addLayer(heat_01) -> map.removeLayer(heat_01);
84
}
85

    
86
function checkDataSetsAvailability(route) {
87

    
88
  var parts = $('#date').val().split('-');
89
  
90
  $.ajax({
91
    type: "POST",
92
    // Todo it might be good idea to change db collections format
93
    url: route + '/' + parts[2] + parts[1] + parts[0],
94
    success: function(result) {
95
      updateAvailableDataSets(result);
96
    }
97
  });
98
}
99

    
100
function updateAvailableDataSets(available) {
101
  
102
  var options;
103
  for (i = 0; i < available.length; i++) {
104
    options += '<options value="' + i + '">' + available[i] + '</option>\n'; 
105
  }
106

    
107
  $('#types').empty().append(options);
108
  
109
}
(6-6/6)