Location.watchPositionAsync triggers only once

#1

I am trying to use Location.watchPositionAsync but it only triggers once when it is loaded in and not when i am moving around. What can cause this?

await Expo.Location.watchPositionAsync({}, function(position){
console.log(position);
_this.props.setPosition(position.coords.latitude, position.coords.longitude);
});

0 Likes

#2

Hey there, I am using this feature as well. Works fine here. You haven’t set the distanceInterval in your code. You should set that to a proper value, also for performance reasons.


        // Set listener to fire on movement/location change.
        Expo.Location.watchPositionAsync(
            {distanceInterval: this.statics.distanceInterval},
            this.handlePositionChange
        );

Hope this helps.

Cheers!

0 Likes