【发布时间】:2023-07-15 19:26:02
【问题描述】:
我正在使用 Capacitor 构建我的 Ionic 应用程序。 我当然想通过 GPS 在地图上显示当前位置的应用程序。
以下代码可以正常工作,并为我提供了我想要的地图上的正确标记,但是.. 它远非准确。
async getLocation() {
var self = this;
let location = await Geolocation.getCurrentPosition({
enableHighAccuracy: true,
timeout: 1000
});
self.marker.setLngLat([location.coords.longitude, location.coords.latitude])
const wait = Geolocation.watchPosition({enableHighAccuracy: true, timeout: 1000}, (position, err) => {
self.marker.setLngLat([position.coords.longitude, position.coords.latitude])
});
}
标记正在疯狂地四处走动。发生在我测试它的每个位置。它移动的不是厘米,而是我所在位置周围的米......
我错过了什么导致 GPS 坐标不太准确?我以为enableHighAccuracy: true 就够了,但事实并非如此。
【问题讨论】:
标签: cordova ionic-framework ionic4 ionic-native capacitor