-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.htm
347 lines (300 loc) · 13.9 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
<!DOCTYPE html>
<!--
all-the-maps - Links to all the map services for a latitude/longitude location
Copyright 2023 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>
<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="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20100%20100%22%3E%3Ctext%20y%3D%22.9em%22%20font-size%3D%2290%22%3E%F0%9F%97%BA%EF%B8%8F%3C%2Ftext%3E%3C%2Fsvg%3E" />
<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; }
.statements p { display: block !important; font-size: small !important; }
.source { margin-left: 2em; }
a.button { margin: 1ex; background-color: #fff; color: #000; text-decoration: none; }
.sans { font-family: sans-serif; }
.emoji { font-size: 64px; vertical-align: bottom; }
</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="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">?</span>s ago<br>
</span>
<br>
Location information is only used within your web browser to create links that you distribute.
</p>
<nav>
<ul>
<li><a href="#">Enter location</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(true)" style="visibility: hidden">Retry</a></li>
</ul>
</nav>
</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="96px" height="96px" src="/Openstreetmap_logo.svg" alt="OpenStreetMap"></a></li>
<li><a id="android" class="button" title="Open in Android App"><img style="min-width: 81px" height="96px" src="/Android_robot.svg" alt="Android App"></a></li>
<li><a id="google" class="button" title="Google Maps"><img width="96px" 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="48px" 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="96px" src="/Wikimedia_Cloud_Services_logo_with_text.svg"
alt="Wikimedia Cloud Services"><br><span class="sans">GeoHack</span></a></li>
<li><a id="clipboard" class="button" href="javascript:copy_location()" title="Copy location to clipboard"><span class="emoji">📋</span></a></li>
<hr>
<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">
<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 design, <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 <q><a href="https://wiki.openstreetmap.org/w/index.php?title=File:Public-images-osm_logo.svg&oldid=2362220">OpenStreetMap logo 2011</a></q>
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="latitude,longitude" autocomplete="on" autofocus required
pattern="[^0-9-]*(-?[1-9]*[0-9]+(?:\.[0-9]+)?)[^0-9-]+(-?[1-9]*[0-9]+(?:\.[0-9]+)?)[^0-9]*">
<input type="submit" value="Go">
<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]+(?:\.[0-9]+)?)[^0-9-]+(-?[1-9]*[0-9]+(?:\.[0-9]+)?)[^0-9]*/;
const strict_lat_long = /^#(-?[1-9]*[0-9]+(?:\.[0-9]+)?,-?[1-9]*[0-9]+(?:\.[0-9]+)?)$/;
var geo_handler = undefined;
var geo_options = {
enableHighAccuracy: true,
timeout: 30000,
maximumAge: 0,
};
var geo_retry = undefined;
var geo_time = undefined;
var geo_timer = undefined;
function goto_location() {
var match = document.getElementById("input").value.match(any_lat_long);
if (match) {
window.location.hash = `${match[1]},${match[2]}`;
}
}
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]+)?)(?:@([2-9]|1[0-9]|2[01]))?$/);
if (match) {
var lat = match[1];
var lon = match[2];
var zoom = match[3];
if (zoom == undefined) {
zoom = "19";
}
document.getElementById("lat_long").innerText = `${lat}, ${lon}`;
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`;
document.getElementById("android").href = `geo:0,0?z=${zoom}&q=${lat},${lon}`;
document.getElementById("google").href = `https://www.google.com/maps?ll=${lat},${lon}&q=${lat},${lon}&t=m&z=${zoom}`;
document.getElementById("apple").href = `https://maps.apple.com/?ll=${lat},${lon}&q=${lat},${lon}&t=m&z=${zoom}`;
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(true);
}
}
}
}
function reset_location() {
window.location.hash = "";
if (window.location.search != "") {
window.location.search = "";
}
}
function copy_url() {
navigator.clipboard.writeText(window.location.href);
}
function copy_location() {
navigator.clipboard.writeText(document.getElementById("input").value);
}
function focus_location() {
document.getElementById("input").focus();
}
function geo_restart(clear) {
geo_stop(true);
if (window.location.hash != "#find") {
return;
}
document.getElementById("details").style = "visibility: hidden";
document.getElementById("geo_lat").innerText = "?";
document.getElementById("geo_lon").innerText = "?";
document.getElementById("geo_acc").innerText = "?";
if (clear) {
document.getElementById("updated").style = "visibility: hidden";
document.getElementById("when").innerText = "?";
}
document.getElementById("retry").style = "visibility: hidden";
document.getElementById("use").style = "visibility: hidden";
if (navigator.geolocation) {
document.getElementById("status").innerText = "Waiting for location";
geo_updated(false);
geo_handler = navigator.geolocation.watchPosition(geo_success, geo_error, geo_options);
} else {
geo_unavailable();
}
}
function geo_updated(available) {
if (geo_timer != undefined) {
clearInterval(geo_timer);
}
if (available) {
document.getElementById("details").style = "";
document.getElementById("retry").style = "visibility: hidden";
document.getElementById("use").style = "";
} else {
document.getElementById("details").style = "visibility: hidden";
document.getElementById("retry").style = "";
document.getElementById("use").style = "visibility: hidden";
}
geo_time = Date.now();
geo_relative_time();
geo_timer = setInterval(geo_relative_time, 500);
}
function geo_relative_time() {
document.getElementById("updated").style = "";
document.getElementById("when").innerText = `${Math.round((Date.now() - geo_time) / 1000)}`;
}
function geo_success(pos) {
document.getElementById("status").innerText = "Location found";
document.getElementById("geo_lat").innerText = `${pos.coords.latitude}`;
document.getElementById("geo_lon").innerText = `${pos.coords.longitude}`;
document.getElementById("geo_acc").innerText = `${pos.coords.accuracy.toFixed(2)}`;
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 = "Position 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_auto_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;
}
}
}
function geo_auto_restart() {
geo_restart(false);
}
function use_location() {
var lat = document.getElementById("geo_lat").innerText;
var lon = document.getElementById("geo_lon").innerText;
document.getElementById("input").value = `${lat},${lon}`;
goto_location();
}
window.onload = update_location;
window.onhashchange = update_location;
update_location();
//]]></script>
</body>
</html>