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
|
const latlon = location.hash.substring(1);
const [lat, lon] = latlon.split(',');
function getLinks(lat, lon) {
return [
{
label: 'Google Maps',
url: `https://www.google.com/maps/search/?api=1&query=${lat},${lon}`,
},
{
label: 'Apple Maps',
url: `https://maps.apple.com/?q=${lat},${lon}&t=m`
},
{
label: 'Default app',
url: `geo:${lat},${lon}`
},
{
label: 'OpenStreetMap',
url: `https://www.openstreetmap.org/?mlat=${lat}&mlon=${lon}&zoom=15&layers=M`
},
]
}
const heading = document.getElementById('heading');
// TODO: listen on hashChange
if (isNaN(lat) || isNaN(lon)) {
heading.textContent = 'not yet implemented';
} else {
const linkList = document.getElementById('links');
document.getElementById('instructions').hidden = false;
document.title = 'Open location';
for (const link of getLinks(lat, lon)) {
const li = document.createElement('li');
const a = document.createElement('a');
a.href = link.url;
a.textContent = link.label;
li.appendChild(a);
linkList.appendChild(li);
}
}
|