任一存 hace 1 año
padre
commit
5a4d8af6b9
Se han modificado 1 ficheros con 18 adiciones y 0 borrados
  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() {