michalchudziak / react-native-geolocation

Geolocation APIs for React Native
MIT License
1.27k stars 219 forks source link

watchPosition options are not working as expected #295

Open MelihaDuman opened 6 months ago

MelihaDuman commented 6 months ago

I am trying to use watchPosition. I am using Android and I tested with a real device.

   const watchId = Geolocation.watchPosition(
      position => {
        const latitude = position.coords.latitude;
        const longitude = position.coords.longitude;
        setLatitude(latitude);
        setLongitude(longitude);
        setSubscriptionId(watchId);
      },
      error => {
        console.log('Error getting location:', error);
      },
      {distanceFilter: 1, maximumAge: 1000, interval:5000},
    );

Even though I change options and option values position is updated only every 20 second regardless distanceFilter and interval values.

gaspop commented 5 months ago

I'm not having luck with this function on Android either, feels like I've tried every variation of options. It will get an initial position but it never updates. I ended up updating the position manually with an interval instead.