-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.htm
497 lines (426 loc) · 19.4 KB
/
index.htm
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
<!DOCTYPE html>
<!--
all-the-maps - Links to all the map services for a latitude/longitude location
Copyright 2023-2024 Simon Arlott
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<html lang="en">
<head>
<title id="title">All The Maps</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="icon" type="image/svg+xml" href="noto-emoji_u1f5fa.svg"/>
<style type="text/css">
.page, .page:target ~ .default-page { display: none; }
.default-page, .page:target { display: block; }
#location h1, #location p { display: inline; font-size: medium; }
nav ul { list-style-type: none; margin: 0; padding: 0; }
nav ul li { display: inline; }
nav a { display: inline-block; margin: 1ex 0 1ex 0; padding: 1ex; border: 1px solid; border-radius: 1ex; text-align: center; }
input { font-size: large; }
#location .statements p { display: block; font-size: small; }
.source { margin-left: 2em; }
a.button, a.button_t { margin: 1ex; text-decoration: none; }
a.button { color: #000 !important; background-color: #FFF !important; }
img.icon_r { padding: 0 0 0 0.5ch; margin: 0; }
.emoji { font-size: 64px; vertical-align: bottom; }
@media (prefers-color-scheme: light) {
body { color: #000; background-color: #FFF; }
a { color: #00E; }
a:visited { color: #551A8B; }
a:active { color: #E00; }
nav a { border-color: #000; }
}
@media (prefers-color-scheme: dark) {
body { color: #FBFBFE; background-color: #1C1B22; }
a { color: #8C8CFF; }
a:visited { color: #FFADFF; }
a:active { color: #F66; }
nav a { border-color: #999; }
}
</style>
</head>
<body>
<noscript>I don't like JavaScript either but it's the only way to get your location and avoid transmitting locations to the webserver.</noscript>
<div id="find" class="page">
<h1>Current Location</h1>
<p>
<span id="status">⏳ Loading</span><br>
<span id="attempt" style="visibility: hidden">
<span id="when_attempt">Last attempt: ?s ago</span><br>
</span>
<span id="details" style="visibility: hidden">
<br>
Latitude: <span id="geo_lat">?</span><br>
Longitude: <span id="geo_lon">?</span><br>
Accuracy: ±<span id="geo_acc">?</span>m<br>
</span>
<span id="updated" style="visibility: hidden">
<br>
Last updated: <span id="when_updated">?</span>s ago<br>
</span>
</p>
<nav>
<ul>
<li><a href="#" title="Enter location">Manual entry</a></li>
<li><a id="use" href="javascript:use_location()" style="visibility: hidden">Use location</a></li>
<li><a id="retry" href="javascript:geo_restart()" style="visibility: hidden">Retry</a></li>
<li><a id="share_loc" href="javascript:share_location()" style="visibility: hidden">Share location<img class="icon_r" src="Material_Design_share.svg" width="16" height="16" alt=""></a></li>
</ul>
</nav>
<p>Location information is only used within your web browser to create links that you distribute.</p>
<p>The location is refreshed automatically by your web browser whenever it changes.</p>
</div>
<div id="location" class="page">
<h1>Location:</h1>
<p><span id="lat_long">?, ?</span></p>
<nav>
<ul>
<li><a id="osm" class="button" title="OpenStreetMap"><img width="96" height="96" src="Openstreetmap_logo.svg" alt="OpenStreetMap"></a></li>
<li><a id="android" class="button" title="Open in an Android application"><img style="min-width: 110px" height="96" src="Android_logo_2019_(stacked).svg" alt="Android App"></a></li>
<li><a id="google" class="button" title="Google Maps"><img width="96" style="min-height: 86px" src="Google_Maps_logo_2020.svg" alt="Google Maps"></a></li>
<li><a id="apple" class="button" title="Apple Maps"><img style="min-width: 157px" height="48" src="Apple_Maps_logo.svg" alt="Apple Maps"></a></li>
<li><a id="geohack" class="button" title="Wikimedia GeoHack"><img style="min-width: 83px" height="96" src="Wikimedia_Cloud_Services_logo_with_text.svg"
alt="Wikimedia Cloud Services"></a></li>
<li><a id="bing" class="button" title="Bing Maps"><img style="min-width: 118px" height="48" src="Bing_Fluent_Logo_Text.svg" alt="Bing Maps"></a></li>
<li><a id="clipboard" class="button" href="javascript:copy_location()" title="Copy location to clipboard"><span class="emoji">📋</span></a></li>
<li><a id="share_url" class="button_t" style="display: none" href="javascript:share_url()" title="Share URL"><img width="64" height="64" src="Material_Design_share.svg" alt="Share URL"></a></li>
</ul>
<hr>
<ul>
<li><a href="javascript:reset_location()">Change location</a></li>
<li><a href="javascript:copy_url()" title="Copy URL to clipboard">Copy to clipboard</a></li>
</ul>
</nav>
<hr>
<div class="statements" role="note">
<p>The OpenStreetMap magnifying glass logo and <q>OpenStreetMap</q> are trademarks of the <a href="https://www.osmfoundation.org/">OpenStreetMap Foundation</a>,
and are used with their <a href="https://wiki.osmfoundation.org/wiki/Trademark_Policy" title="OpenStreetMap Trademark Policy">permission</a>.
This website is not endorsed by or affiliated with the OpenStreetMap Foundation.</p>
<p>The Android robot, <q>Android</q> and <q>Google</q> are registered trademarks of <a href="https://about.google/">Google LLC</a>.
This website is not endorsed by or affiliated with Google LLC.</p>
<p>The Apple logo and <q>Apple</q> are trademarks of <a href="https://www.apple.com/">Apple Inc.</a>, registered in the U.S. and other countries and regions.
This website is not endorsed by or affiliated with Apple Inc.</p>
<p>The Wikimedia Cloud Services logo and <q>Wikimedia</q> are trademarks of the <a href="https://wikimediafoundation.org/">Wikimedia Foundation</a>
and are used with the <a href="https://foundation.wikimedia.org/wiki/Policy:Trademark_policy" title="Wikimedia Foundation Trademark Policy">permission</a>
of the Wikimedia Foundation. This website is not endorsed by or affiliated with the Wikimedia Foundation.</p>
<p>The Bing logo, <q>Bing</q> and <q>Microsoft</q> are trademarks of the <a href="https://www.microsoft.com/">Microsoft</a> group of companies.
This website is not endorsed by or affiliated with Microsoft.</p>
<p>The <q><a href="https://commons.wikimedia.org/wiki/File:Android_logo_2019_(stacked).svg">Android logo 2019</a></q>
image is reproduced or modified from
<a href="https://developer.android.com/distribute/marketing-tools/brand-guidelines#android_robot">work created and shared by Google</a>
and used according to terms described in the <a href="https://en.wikipedia.org/wiki/Creative_Commons">Creative Commons</a>
<a href="https://creativecommons.org/licenses/by/3.0/deed.en">Attribution 3.0 Unported</a> licence.
<p>The <q><a href="https://wiki.openstreetmap.org/w/index.php?title=File:Public-images-osm_logo.svg&oldid=2362220">OpenStreetMap logo 2011</a></q>
image is licensed under the <a href="https://en.wikipedia.org/wiki/Creative_Commons">Creative Commons</a>
<a href="https://creativecommons.org/licenses/by-sa/3.0/deed.en">Attribution-ShareAlike 3.0 Unported</a> licence. It was authored by
<a href="https://kver.ca/">Ken Vermette</a> in 2010
<a href="https://wiki.openstreetmap.org/w/index.php?title=Talk:Logos&oldid=2531072#History_of_the_OpenStreetMap_logo">based on a design
by Matt Amos and Steve Coast</a>.
<p>The <q><a href="https://foundation.wikimedia.org/wiki/File:Wikimedia_Cloud_Services_logo_with_text.svg">Wikimedia Cloud Services logo</a></q>
image is licensed under the <a href="https://en.wikipedia.org/wiki/Creative_Commons">Creative Commons</a>
<a href="https://creativecommons.org/licenses/by-sa/3.0/deed.en">Attribution-ShareAlike 3.0 Unported</a> licence. It was authored by
<a href="https://commons.wikimedia.org/wiki/User:Jorm_(WMF)" title="User:Jorm (WMF)">Brandon Harris</a> and
<a href="https://commons.wikimedia.org/wiki/User:Isarra" title="User:Isarra">some idiot who keeps forgetting her username</a>
on 2012-06-12.</p>
<p><a href="https://github.com/nomis/all-the-maps">Source code</a></p>
</div>
</div>
<div id="start" class="page default-page">
<h1>🗺️ All The Maps</h1>
<nav><h2><a href="#find">Get current location</a></h2></nav>
<form action="javascript:goto_location()" onreset="javascript:focus_location()">
<h2>Enter <label for="location">Location</label></h2>
<input id="input" type="text" name="location" size="20"
placeholder="lat. & long. (any separators)" autocomplete="on" autofocus required
title="latitude & longitude (using any decimal separator and any list separator)"
pattern="[^0-9\-]*(-?[1-9]*[0-9]+(?:[.,٫][0-9]+)?)[^0-9.٫\-]+(-?[1-9]*[0-9]+(?:[.,٫][0-9]+)?)[^0-9]*">
<input type="submit" value="Go">
<!--
Keep vertical content below the text input element to the absolute minimum
because the web browser may try and scroll down until it's at the top of
the screen when focusing on it, hiding everything above the input box.
-->
<br><br><br>
<input type="reset" value="Clear">
<a class="source" href="https://github.com/nomis/all-the-maps">Source code</a>
</form>
</div>
<script type="text/javascript">//<![CDATA[
const any_lat_long = /[^0-9-]*(-?[1-9]*[0-9]+(?:[.,\u066b][0-9]+)?)[^0-9.\u066b-]+(-?[1-9]*[0-9]+(?:[.,\u066b][0-9]+)?)[^0-9]*/u;
var geo_handler = undefined;
var geo_options = {
enableHighAccuracy: true,
timeout: 30000,
maximumAge: 0,
};
var geo_retry = undefined;
var geo_time_u = undefined;
var geo_time_a = undefined;
var geo_time_w = undefined;
var geo_timer = undefined;
function goto_location() {
var match = document.getElementById("input").value.match(any_lat_long);
if (match) {
var lat = match[1].replace(/[,\u066b]/ug, ".");
var lon = match[2].replace(/[,\u066b]/ug, ".");
window.location.hash = `${lat},${lon}`;
}
}
function update_location() {
if (window.location.search != "") {
window.location.search = "";
}
if (window.location.hash != "#find") {
geo_stop(true);
}
var match = location.hash.match(/^#(-?[1-9]*[0-9]+(?:\.[0-9]+)?),(-?[1-9]*[0-9]+(?:\.[0-9]+)?)(?:~([1-9]*[0-9]+(?:\.[0-9]+)?))?(?:@([2-9]|1[0-9]|2[01]))?$/);
if (match) {
var lat = match[1];
var lon = match[2];
var acc = match[3];
var zoom = match[4];
var now = Date.now() / 1000;
if (zoom == undefined) {
zoom = "19";
}
document.getElementById("lat_long").innerText = make_text(lat, lon, acc);
document.getElementById("input").value = `${lat},${lon}`;
document.getElementById("start").style = "display: none;";
document.getElementById("location").style = "display: block";
document.getElementById("title").innerText = `All The Maps (${lat}, ${lon})`;
document.getElementById("osm").href = `https://www.openstreetmap.org/?mlat=${lat}&mlon=${lon}&zoom=${zoom}&layers=M`;
/* Android:
* `geo:${lat},${lon}` is the map position (0,0 is the user's location)
* `q=${lat},${lon}` is the search query (for dropped pin and directions)
* `(${lat},${lon})` is the search query name
*/
document.getElementById("android").href = `geo:${lat},${lon}?z=${zoom}&q=${lat},${lon}(${lat},${lon})`;
/* Google Maps:
* `ll=${lat},${lon}` is the map position
* `q=${lat},${lon}&t=m&z=${zoom}` is the search query (for dropped pin and directions)
*/
document.getElementById("google").href = `https://www.google.com/maps?ll=${lat},${lon}&q=${lat},${lon}&t=m&z=${zoom}`;
/* Apple Maps:
* `ll=${lat},${lon}` is the map position and dropped pin
* `q=${lat},${lon}` is the name of the location
* `ll=` and `q=` together will stop it redirecting to Google Maps on non-Apple devices 🙄
*/
document.getElementById("apple").href = `https://maps.apple.com/?ll=${lat},${lon}&q=${lat},${lon}&t=m&z=${zoom}`;
/* Bing Maps:
* `cp=${lat}~${lon}` is the map position
* `where1=${lat},${lon}` is the search query (for dropped pin and directions)
*/
document.getElementById("bing").href = `https://www.bing.com/maps/?v=2&cp=${lat}~${lon}&style=r&lvl=${zoom}&where1=${lat},${lon}`;
/* GeoHack:
* `_dim:1` is the zoom level (object size in metres)
*/
document.getElementById("geohack").href = `https://geohack.toolforge.org/geohack.php?language=en¶ms=${lat};${lon}_dim:1`;
} else {
document.getElementById("location").style = "";
document.getElementById("start").style = "";
document.getElementById("title").innerText = "All The Maps";
if (window.location.hash == "" || window.location.hash == "#") {
focus_location();
} else if (window.location.hash == "#find") {
if (geo_handler == undefined) {
geo_restart();
}
if (geo_timer == undefined && (geo_time_u != undefined || geo_time_a != undefined)) {
geo_relative_timer();
}
}
}
}
function reset_location() {
window.location.hash = "";
if (window.location.search != "") {
window.location.search = "";
}
}
function copy_url() {
navigator.clipboard.writeText(window.location.href);
}
async function share(url, text) {
const data = {
title: `Location (${text})`,
url: url,
};
if (navigator.canShare(data)) {
await navigator.share(data);
} else {
alert("Sharing not allowed");
}
}
function share_location() {
share(`${window.location.origin}${window.location.pathname}#${make_hash(true)}`, make_geo_text());
}
function share_url() {
share(window.location.href, document.getElementById("lat_long").innerText);
}
function copy_location() {
navigator.clipboard.writeText(document.getElementById("input").value);
}
function focus_location() {
document.getElementById("input").focus();
}
function geo_restart() {
geo_stop(true);
if (window.location.hash != "#find") {
return;
}
var retry = document.getElementById("retry");
retry.innerText = "Retry";
retry.style = "";
if (navigator.geolocation) {
document.getElementById("status").innerText = "⏳ Requesting your location";
geo_time_w = Date.now();
geo_relative_timer();
geo_handler = navigator.geolocation.watchPosition(geo_success, geo_error, geo_options);
} else {
geo_unavailable();
}
}
function geo_updated(available) {
var retry = document.getElementById("retry");
if (available) {
document.getElementById("details").style = "";
document.getElementById("use").style = "";
if (navigator.share) {
document.getElementById("share_loc").style = "";
}
retry.innerText = "Refresh";
geo_time_u = Date.now();
geo_time_a = undefined;
} else {
retry.innerText = "Retry";
geo_time_a = Date.now();
}
retry.style = "";
geo_time_w = undefined;
geo_relative_timer();
}
function geo_relative_timer() {
if (geo_timer != undefined) {
clearInterval(geo_timer);
}
geo_relative_time();
geo_timer = setInterval(geo_relative_time, 500);
}
function geo_relative_time() {
if (geo_time_u != undefined) {
document.getElementById("when_updated").innerText = `${Math.round((Date.now() - geo_time_u) / 1000)}`;
document.getElementById("updated").style = "";
} else {
document.getElementById("updated").style = "visibility: hidden";
}
if (geo_time_w != undefined) {
document.getElementById("when_attempt").innerText = `Waiting for: ${Math.round((Date.now() - geo_time_w) / 1000)}s`;
document.getElementById("attempt").style = "";
} else if (geo_time_a != undefined) {
document.getElementById("when_attempt").innerText = `Last attempt: ${Math.round((Date.now() - geo_time_a) / 1000)}s ago`;
document.getElementById("attempt").style = "";
} else {
document.getElementById("attempt").style = "visibility: hidden";
}
}
function round_num(value, digits) {
return value.toLocaleString("en", {minimumFractionDigits: Math.min(digits, 1), maximumFractionDigits: digits, useGrouping: false})
}
function geo_success(pos) {
document.getElementById("status").innerText = "✅ Location found";
var acc_digits = pos.coords.accuracy < 100 ? 2 : (pos.coords.accuracy < 1000 ? 1 : 0);
document.getElementById("geo_lat").innerText = `${round_num(pos.coords.latitude, 8)}`;
document.getElementById("geo_lon").innerText = `${round_num(pos.coords.longitude, 8)}`;
document.getElementById("geo_acc").innerText = `${round_num(pos.coords.accuracy, acc_digits)}`;
geo_updated(true);
}
function geo_error(err) {
var message = "⚠️ Unknown error";
var failed = false;
if (err.code == err.PERMISSION_DENIED) {
message = "🚫 Permission denied (you need to allow this website to access your location)";
failed = true;
} else if (err.code == err.POSITION_UNAVAILABLE) {
message = "❌ Location unavailable";
} else if (err.code == err.TIMEOUT) {
message = "⚠️ Timeout occurred";
} else {
message = `⚠️ Unknown error ${err.code}`;
failed = true;
}
document.getElementById("status").innerText = message;
geo_updated(false);
if (failed) {
geo_stop(false);
} else {
geo_stop(false);
geo_retry = setTimeout(geo_restart, 3000);
}
}
function geo_unavailable() {
document.getElementById("status").innerText = "🛑 Location not supported";
geo_updated(false);
}
function geo_stop(all) {
if (geo_handler != undefined) {
navigator.geolocation.clearWatch(geo_handler);
geo_handler = undefined;
}
if (geo_retry != undefined) {
clearTimeout(geo_retry);
geo_retry = undefined;
}
if (all) {
if (geo_timer != undefined) {
clearInterval(geo_timer);
geo_timer = undefined;
}
document.getElementById("attempt").style = "visibility: hidden";
geo_time_w = undefined;
}
}
function make_hash(with_acc) {
var lat = document.getElementById("geo_lat").innerText;
var lon = document.getElementById("geo_lon").innerText;
var acc = document.getElementById("geo_acc").innerText;
if (with_acc) {
return `${lat},${lon}~${acc}`;
} else {
return `${lat},${lon}`;
}
}
function make_text(lat, lon, acc) {
if (acc == undefined) {
acc = "";
} else {
acc = ` ±${acc}m`;
}
return `${lat}, ${lon}${acc}`;
}
function make_geo_text() {
var lat = document.getElementById("geo_lat").innerText;
var lon = document.getElementById("geo_lon").innerText;
var acc = document.getElementById("geo_acc").innerText;
return make_text(lat, lon, acc);
}
function use_location() {
document.getElementById("input").value = make_hash(false);
window.location.hash = make_hash(true);
}
window.onload = update_location;
window.onhashchange = update_location;
document.getElementById("share_loc").style = navigator.share ? "visibility: hidden" : "display: none";
document.getElementById("share_url").style = navigator.share ? "" : "display: none";
update_location();
//]]></script>
</body>
</html>