michalchudziak / react-native-geolocation

Geolocation APIs for React Native
MIT License
1.31k stars 228 forks source link

Speed value returns -1 and 0 #238

Open MRadek55 opened 1 year ago

MRadek55 commented 1 year ago

Hey everyone!

I have encountered a problem with speed and heading from watchPosition listener

  useEffect(() => {
    const watchId = Geolocation.watchPosition(({ coords }) => {
      const { latitude: lat, longitude: lng } = coords;
      setCurrentLocation({ lat, lng });
    }, (err) => console.log(err), {
      enableHighAccuracy: true,
    });

    return () => {
      Geolocation.clearWatch(watchId);
    };
  }, []);

The lng and lat values work fine, but the two above are 0 (on Android) and -1 (for iOS) for speed and -1 for heading.

I'm using fake GPS for Android while testing and prepared GPX file for iOS

Thanks in advance!

matheusyuri7 commented 1 year ago

@MRadek55 have you found a solution for this? I`m facing the same issue

MRadek55 commented 1 year ago

@MRadek55 have you found a solution for this? I`m facing the same issue

I realized that it is only when we are using fake gps or gpx simulation. On real tests it works fine