浏览代码

Enable high accuracy position

Harry de Boer 6 年之前
父节点
当前提交
603f29c657
共有 1 个文件被更改,包括 14 次插入2 次删除
  1. 14 2
      src/main/resources/static/main.js

+ 14 - 2
src/main/resources/static/main.js

@@ -22,8 +22,20 @@ class Puzzeltocht {
             document.getElementById("unsupported").style.display = "block";
         }
 
-        navigator.geolocation.getCurrentPosition((pos) => Puzzeltocht.updateLocation(pos));
-        navigator.geolocation.watchPosition((pos) => Puzzeltocht.updateLocation(pos));
+        const geoOpts = {
+            enableHighAccuracy: true,
+            maximumAge        : 5000,
+            timeout           : 4500
+        };
+
+        navigator.geolocation.getCurrentPosition(
+            (pos) => Puzzeltocht.updateLocation(pos),
+            (err) => console.log(err),
+            geoOpts);
+        navigator.geolocation.watchPosition(
+            (pos) => Puzzeltocht.updateLocation(pos),
+            (err) => console.log(err),
+            geoOpts);
 
         console.log("puzzeltocht initialised");
     }