This repository has no description
1.2 kB
41 lines
1// "open in" links for a coordinate; shared by index.html and at.html.
2// There is no single url every maps app opens, so offer one per app.
3function mapLinks(lat, lon) {
4 // iOS has no handler for geo: (iPadOS reports itself as a Mac)
5 var ios =
6 /iPad|iPhone|iPod/.test(navigator.userAgent) ||
7 (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
8 var ll = lat + "," + lon;
9 var links = [
10 [
11 "Google Maps",
12 "https://www.google.com/maps/search/?api=1&query=" +
13 encodeURIComponent(ll),
14 ],
15 ["Apple Maps", "https://maps.apple.com/?ll=" + ll + "&q=lassulus"],
16 ];
17 // android: app chooser incl. Google Maps, OsmAnd, Organic Maps, ...
18 if (!ios) links.push(["choose app…", "geo:" + ll + "?q=" + ll + "(lassulus)"]);
19 links.push([
20 "OpenStreetMap",
21 "https://www.openstreetmap.org/?mlat=" +
22 lat +
23 "&mlon=" +
24 lon +
25 "#map=16/" +
26 lat +
27 "/" +
28 lon,
29 ]);
30 return links;
31}
32
33function renderMapLinks(container, lat, lon) {
34 container.replaceChildren();
35 mapLinks(lat, lon).forEach(function (l) {
36 var a = document.createElement("a");
37 a.textContent = l[0];
38 a.href = l[1];
39 container.appendChild(a);
40 });
41}