-
Notifications
You must be signed in to change notification settings - Fork 0
/
data-viewer.html
148 lines (112 loc) · 4.81 KB
/
data-viewer.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html>
<html lang="en" class="has-navbar-fixed-top">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>GeoLocation Experiment</title>
<link rel="stylesheet" href="bulma.min.css">
<link rel="stylesheet" href="css/style.css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin="" />
</head>
<body>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script>
<nav class="navbar is-fixed-top">
<div class="navbar-brand">
<a class="navbar-item" href="#">
<img src="./favicon.ico">
</a>
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false"
data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" href="./index.html">Tracker</a>
</div>
<div class="navbar-end">
</div>
</div>
</nav>
<section class="px-5">
<div class="file is-centered is-boxed is-success has-name mb-4">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-label">
Carregar dados
</span>
</span>
<span class="file-name has-text-centered ">
Nenhum arquivo carregado ...
</span>
</label>
</div>
<div class="container is-centered">
<label class="label">
<div class="has-text-centered">
Acurácia (metros)
</div>
<input type="number" max="150" min="10" class="input" placeholder="150">
</label>
<div class="mt-4" id="map"></div>
</div>
</section>
<script type="module">
import leaflet from './leaflet-fns.js'
let map = leaflet.createMap('map')
map.centerMap(0,0)
navigator.geolocation.getCurrentPosition(success => map.centerMap(success.coords.latitude,success.coords.longitude))
const fileInput = document.querySelector('input[type=file]');
const accuracy_val = document.querySelector('input[type=number]')
fileInput.onchange = async () => {
if (fileInput.files.length > 0) {
const fileName = document.querySelector('.file-name');
fileName.textContent = fileInput.files[0].name;
let dataPoints = await getData(fileInput.files[0])
console.log(dataPoints)
map.polyline.updateCoords(dataPoints,accuracy_val.value)
fileInput.value = ''
}
}
async function getData(file) {
return new Promise((resolve, reject) => {
let reader = new FileReader();
reader.onerror = reject;
reader.onload = function (event) {
resolve(JSON.parse(event.target.result))
};
reader.readAsText(file);
});
}
</script>
<script>
document.addEventListener('DOMContentLoaded', () => {
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach(el => {
el.addEventListener('click', () => {
// Get the target from the "data-target" attribute
const target = el.dataset.target;
const $target = document.getElementById(target);
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
});
</script>
</body>
</html>