任一存 1 年之前
父節點
當前提交
5a4d8af6b9
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. 18 0
      src/App.vue

+ 18 - 0
src/App.vue

@@ -117,6 +117,24 @@ function onClickCloseText() {
   isShowText.value = false;
 }
 
+console.log("geolocation: ", navigator.geolocation);
+navigator.geolocation.getCurrentPosition(
+  // navigator.geolocation.watchPosition(
+  (pos) => {
+    console.log(
+      `pos by geolocation: ${pos.coords.longitude}, ${pos.coords.latitude}, ${pos.coords.altitude}, ${pos.coords.accuracy}`
+    );
+  },
+  (err) => {
+    console.error("geolocation error: ", err);
+  },
+  {
+    enableHighAccuracy: true,
+    timeout: 10000,
+    maximumAge: 0,
+  }
+);
+
 // 导航相关
 const isNavigating = ref(false);
 function onClickLocateBtn() {