forked from kallanreed/mesh-map
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgeohashCalc.html
More file actions
45 lines (38 loc) · 1.06 KB
/
geohashCalc.html
File metadata and controls
45 lines (38 loc) · 1.06 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Geohash Calculator</title>
<link rel="stylesheet" type="text/css" href="content/forms.css" />
</head>
<body>
<div>
<div class="form-item">
<label>
Geohash:
<input id="hashTxt">
</label>
</div>
<div class="form-item">
<label>
Lat/Lon:
<input id="latLonTxt">
</label>
</div>
</div>
<script type="module">
import { geohash8, parseLocation, posFromHash } from '/content/shared.js'
const hashTxtEl = document.getElementById("hashTxt");
const latLonEl = document.getElementById("latLonTxt");
hashTxtEl.addEventListener("change", e => {
const [lat, lon] = posFromHash(e.target.value);
latLonEl.value = `${lat.toFixed(4)}, ${lon.toFixed(4)}`;
});
latLonEl.addEventListener("change", e => {
const [latTxt, lonTxt] = e.target.value.split(/,\s*/, 2);
const [lat, lon] = parseLocation(latTxt, lonTxt, false);
const hash = geohash8(lat, lon);
hashTxtEl.value = hash;
});
</script>
</body>
</html>