Agontuk / react-native-geolocation-service

React native geolocation service for iOS and android
https://www.npmjs.com/package/react-native-geolocation-service
MIT License
1.61k stars 292 forks source link

maximumAge is in seconds, not milliseconds #266

Closed wuppious closed 2 years ago

wuppious commented 3 years ago

React Native: 0.64.0 Library version: 5.3.0-beta.1, 5.2.0 Device: Samsung Galaxy A71

The maximumAge option seems to be in seconds, not in milliseconds like described in the documentation. App is using the fused location provider.

mariosantosdev commented 3 years ago

I believe it's a mistake! But you solve my problem!

Agontuk commented 3 years ago

The maximumAge option seems to be in seconds, not in milliseconds like described in the documentation. App is using the fused location provider.

How are you verifying this ? maximumAge is in milliseconds as far as I know.

wuppious commented 3 years ago

getCurrentPosition returns near immediately and the result contains the 'heading', which does not change at all between requests if I set the maximumAge to 5000 but does change if set to 5.

Edit: I mean it changes with 5 second intervals. Obviously inbetween you'll receive cached results.

Agontuk commented 3 years ago

If you're getting same results, check the timestamp. If it's different every time, that means fused provider thinks you're still in the same location. That's why it returning old data, but with new timestamps.

I checked the code, maximumAge is being used as milliseconds. So I don't think it's the real issue.

wuppious commented 3 years ago

I'll provide you with better info next week if I remember. In any case treating maximumAge as seconds resulted in the expected and intended behaviour – atleast in my case.

I'm on Android 11 and Google Play Services 21.15.15 if those help.

FanchenBao commented 3 years ago

I am using Geolocation.watchPosition, and I feel like interval is not in ms but in centisecond. I set it to 1000, and the location updates about every 10 seconds. When I set it to 100, it updates every second.

ZephD commented 3 years ago

Looking at the source code, there are default variables you will need to overwrite in order to get the application to work as indented.

The default interval is 10 seconds and the default fastestInterval is 5 seconds. You must override both of these. There is also a distanceFilter of 100m you need to override.

Try a minimum of: { fastestInterval: 0, distanceFilter: 0 }

With just those options I got 1 second updates.

Agontuk commented 2 years ago

Closing due to inactivity, also I'm confident that this is working as expected. Feel free to open a new issue if that's not the case.