Revize 61ff7718
Přidáno uživatelem Jakub Vašta před asi 4 roky(ů)
website/public/js/zcu-heatmap.js | ||
---|---|---|
1 | 1 |
var mymap; |
2 | 2 |
var heatmapLayer = null; |
3 |
var marksLayer = null; |
|
3 | 4 |
|
4 | 5 |
var startX = 49.7248; |
5 | 6 |
var startY = 13.3521; |
... | ... | |
46 | 47 |
var lat = 0; |
47 | 48 |
var lng = 0; |
48 | 49 |
|
50 |
var total = 0; |
|
49 | 51 |
data[currentTime]['items'].forEach(element => { |
50 | 52 |
if (e.latlng.distanceTo(new L.LatLng(element.x, element.y)) < radius) { |
51 | 53 |
lat += element.x |
52 | 54 |
lng += element.y; |
53 | 55 |
info[i] = {'place' : element.place, 'number' : element.number}; |
56 |
total += parseInt(element.number); |
|
54 | 57 |
i++; |
55 | 58 |
} |
56 | 59 |
}); |
... | ... | |
62 | 65 |
}) |
63 | 66 |
.setLatLng([lat / i, lng / i]) |
64 | 67 |
.setContent('<strong>Zařízení a počet:</strong><div id=\'place-info\'>' + info[currenInfo].place + '</div>' + |
65 |
'<div id=\'number-info\'>' + info[currenInfo].number + '</div>' +
|
|
68 |
'<div id=\'number-info\'><span id=\'digit-info\'>' + info[currenInfo].number + '</span>' + '<span id=\'total-info\' style="font-size: large">/' + total +'</span></div>' +
|
|
66 | 69 |
'<div class=\'popup-controls\'>' + |
67 | 70 |
'<button id=\'previous-info-btn\' class=\'circle-button\' onclick=\'previousInfo()\'></button>' + |
68 |
'<div id=\'count-info\'>' + (currenInfo + 1) + '/' + info.length + '</div>' +
|
|
71 |
'<div id=\'count-info\'>' + (currenInfo + 1) + ' z ' + info.length + '</div>' +
|
|
69 | 72 |
'<button id=\'next-info-btn\' onclick=\'nextInfo()\' class=\'circle-button next\'></button>' + |
70 | 73 |
'</div>' |
71 | 74 |
) |
... | ... | |
92 | 95 |
|
93 | 96 |
function displayInfoText() { |
94 | 97 |
$('#place-info').html(info[currenInfo].place) |
95 |
$('#number-info').html(info[currenInfo].number)
|
|
96 |
$('#count-info').html(currenInfo + 1 + '/' + info.length);
|
|
98 |
$('#digit-info').html(info[currenInfo].number)
|
|
99 |
$('#count-info').html(currenInfo + 1 + ' z ' + info.length);
|
|
97 | 100 |
} |
98 | 101 |
|
99 | 102 |
function setMapView(latitude = startX, longitude = startY, zoom = startZoom) { |
... | ... | |
155 | 158 |
$('#timeline').attr('class', 'time hour-' + currentTime); |
156 | 159 |
} |
157 | 160 |
|
158 |
function loadCurrentTimeHeatmap(route) {
|
|
161 |
function loadCurrentTimeHeatmap(opendataRoute, positionsRoute) {
|
|
159 | 162 |
|
160 |
dataSourceRoute = route; |
|
161 | 163 |
data = [] |
162 | 164 |
|
163 |
name = $('#type').children("option:selected").text();
|
|
165 |
name = $('#type').children("option:selected").val();
|
|
164 | 166 |
date = $('#date').val() |
165 | 167 |
currentTime = parseInt($('#time').children("option:selected").val()); |
166 | 168 |
setTimeline(); |
167 | 169 |
|
168 | 170 |
$.ajax({ |
169 | 171 |
type: "POST", |
170 |
url: dataSourceRoute + '/' + name + '/' + date + '/' + currentTime,
|
|
172 |
url: opendataRoute + '/' + name + '/' + date + '/' + currentTime,
|
|
171 | 173 |
success: function(result) { |
172 | 174 |
data[currentTime] = result; |
173 | 175 |
drawHeatmap(data[currentTime]); |
174 | 176 |
} |
175 | 177 |
}); |
176 | 178 |
|
179 |
$.ajax({ |
|
180 |
type: 'POST', |
|
181 |
url: positionsRoute + '/' + name, |
|
182 |
success: function(result) { |
|
183 |
drawDataSourceMarks(result) |
|
184 |
} |
|
185 |
}); |
|
186 |
|
|
177 | 187 |
preload(currentTime, 1); |
178 | 188 |
preload(currentTime, -1); |
179 | 189 |
|
180 | 190 |
} |
181 | 191 |
|
192 |
function drawDataSourceMarks(data) { |
|
193 |
|
|
194 |
if (marksLayer != null) { |
|
195 |
L.removeLayer(marksLayer); |
|
196 |
} |
|
197 |
|
|
198 |
marksLayer = L.layerGroup(); |
|
199 |
for (var key in data) { |
|
200 |
marksLayer.addLayer(L.circle([data[key]['x'], data[key]['y']], {radius: 1, color: 'black'})); |
|
201 |
} |
|
202 |
|
|
203 |
marksLayer.addTo(mymap); |
|
204 |
|
|
205 |
} |
|
206 |
|
|
182 | 207 |
function preload(time, change) { |
183 | 208 |
|
184 | 209 |
var ntime = time + change; |
Také k dispozici: Unified diff
Re #8092, Re #8085
+ data source points location layer - circles
+ total number of activity in aggregation