我正在使用 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
足够了,但事实并非如此。