Add Navigation Arrow and simplify static page
This commit is contained in:
@@ -1,18 +1,61 @@
|
||||
(function (ns) {
|
||||
'use strict';
|
||||
|
||||
let watchId = null;
|
||||
function normalize(position) { return { lat: position.coords.latitude, lon: position.coords.longitude, accuracy: position.coords.accuracy, timestamp: position.timestamp }; }
|
||||
|
||||
function normalize(position) {
|
||||
return {
|
||||
lat: position.coords.latitude,
|
||||
lon: position.coords.longitude,
|
||||
accuracy: position.coords.accuracy,
|
||||
altitude: position.coords.altitude,
|
||||
heading: position.coords.heading,
|
||||
speed: position.coords.speed,
|
||||
timestamp: position.timestamp
|
||||
};
|
||||
}
|
||||
|
||||
ns.Geo = {
|
||||
current() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!navigator.geolocation) return reject(new Error('Dieses Gerät unterstützt keine Geolokalisierung.'));
|
||||
navigator.geolocation.getCurrentPosition(p => resolve(normalize(p)), reject, { enableHighAccuracy: true, timeout: ns.Config.geolocationTimeoutMs, maximumAge: 30000 });
|
||||
if (!navigator.geolocation) {
|
||||
reject(new Error('Dieses Gerät unterstützt keine Geolokalisierung.'));
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
position => resolve(normalize(position)),
|
||||
reject,
|
||||
{
|
||||
enableHighAccuracy: true,
|
||||
timeout: ns.Config.geolocationTimeoutMs,
|
||||
maximumAge: 30000
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
start(callback, onError) {
|
||||
this.stop();
|
||||
watchId = navigator.geolocation.watchPosition(p => callback(normalize(p)), onError, { enableHighAccuracy: true, timeout: 20000, maximumAge: 5000 });
|
||||
if (!navigator.geolocation) {
|
||||
onError?.(new Error('Dieses Gerät unterstützt keine Geolokalisierung.'));
|
||||
return;
|
||||
}
|
||||
|
||||
watchId = navigator.geolocation.watchPosition(
|
||||
position => callback(normalize(position)),
|
||||
onError,
|
||||
{
|
||||
enableHighAccuracy: true,
|
||||
timeout: 20000,
|
||||
maximumAge: 5000
|
||||
}
|
||||
);
|
||||
},
|
||||
stop() { if (watchId != null) navigator.geolocation.clearWatch(watchId); watchId = null; }
|
||||
|
||||
stop() {
|
||||
if (watchId != null) navigator.geolocation.clearWatch(watchId);
|
||||
watchId = null;
|
||||
}
|
||||
};
|
||||
}(window.Wegwichtel));
|
||||
|
||||
Reference in New Issue
Block a user