|
|
@@ -24,30 +24,32 @@ class Puzzeltocht {
|
|
|
|
|
|
const geoOpts = {
|
|
|
enableHighAccuracy: true,
|
|
|
- maximumAge : 5000,
|
|
|
- timeout : 4500
|
|
|
+ maximumAge : 10000,
|
|
|
+ timeout : 9500
|
|
|
};
|
|
|
|
|
|
navigator.geolocation.getCurrentPosition(
|
|
|
- (pos) => Puzzeltocht.updateLocation(pos),
|
|
|
+ (pos) => p.updateLocation(pos),
|
|
|
(err) => console.log(err),
|
|
|
geoOpts);
|
|
|
navigator.geolocation.watchPosition(
|
|
|
- (pos) => Puzzeltocht.updateLocation(pos),
|
|
|
+ (pos) => p.updateLocation(pos),
|
|
|
(err) => console.log(err),
|
|
|
geoOpts);
|
|
|
|
|
|
console.log("puzzeltocht initialised");
|
|
|
}
|
|
|
|
|
|
- static updateLocation(pos) {
|
|
|
+ updateLocation(pos) {
|
|
|
let l = document.getElementById("location");
|
|
|
let lat = pos.coords.latitude;
|
|
|
let long = pos.coords.longitude;
|
|
|
- let ts = new Date();
|
|
|
- ts.setTime(pos.timestamp);
|
|
|
+ let ts = new Date(pos.timestamp);
|
|
|
l.innerText = "positie: " + lat + ", " + long + ", " + pos.coords.accuracy + " (updated " + ts.toUTCString() + ")";
|
|
|
- Puzzeltocht.updateMap(pos);
|
|
|
+ if (this.lastUpdate === undefined || this.lastUpdate + 30000 < pos.timestamp) {
|
|
|
+ this.lastUpdate = pos.timestamp;
|
|
|
+ Puzzeltocht.updateMap(pos);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
static updateMap(pos) {
|
|
|
@@ -59,4 +61,5 @@ class Puzzeltocht {
|
|
|
url = url + "&markers=" + lat + "," + long + ",lightblue1";
|
|
|
img.src = url;
|
|
|
}
|
|
|
+
|
|
|
}
|