-
Notifications
You must be signed in to change notification settings - Fork 1
/
logviewer.map.js
37 lines (33 loc) · 1.05 KB
/
logviewer.map.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function constructMap() {
if(dataStore.lat==undefined || dataStore.lon==undefined) {
return;
}
if(!(dataStore.map==undefined)) {
dataStore.map.remove()
}
var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var osmAttrib='Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';
var osm = new L.TileLayer(osmUrl, {minZoom: 8, maxZoom: 20, attribution: osmAttrib});
var origLat=51.505;
var origLon=-0.09;
for(var i=0;i<dataStore.lat.length;i++){
if(!isNaN(dataStore.lat[i]) && !isNaN(dataStore.lon[i])) {
origLat=dataStore.lat[i];
origLon=dataStore.lon[i];
break;
}
}
dataStore.map=L.map('map').setView([origLat,origLon], 15).addLayer(osm);
dataStore.marker=L.marker([origLat,origLon]).addTo(dataStore.map)
}
function updateMap(event, x, points, row, seriesName) {
if(dataStore.lat==undefined || dataStore.lon==undefined) {
return;
}
var lat = dataStore.lat[row]
var lon = dataStore.lon[row]
if(!isNaN(lat) && !isNaN(lon)) {
dataStore.map.panTo([lat,lon])
dataStore.marker.setLatLng([lat,lon])
}
}