Thursday, 6 June 2019

Ionic4 watchPosition and getCurrentPosition of Geolocation not accurate with Ionic/Capacitor

I'm using Capacitor for building my Ionic app. I the app I wanna show the current position on a Map via GPS of course.

The following code works and gives me the correct Marker on the Map as I want to, but.. It's far from accurate.

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([self.user_longitude, position.coords.latitude])
    });
}

The Marker is going around like crazy. Happens on every location I test it on. It's moving not centimeters, but meters around my location...

What am I missing that is giving me the less accurate GPS coordinates? I thought enableHighAccuracy: true was enough, but that's not it.



from Ionic4 watchPosition and getCurrentPosition of Geolocation not accurate with Ionic/Capacitor

No comments:

Post a Comment