Michael
Michael

Reputation: 1874

Geolocation accuracy in React Native

I'd like to use two geo location watchers in my app. One with useSignificantChangesand one with high accuracy.

The "lowres" watcher would provide my Redux store with approximate locations all the time, whereas the "highres" watcher would be enabled when the user is working in a live view.

Here are the options for the low res watcher

const options = {
  enableHighAccuracy: false,
  useSignificantChanges: true,
  distanceFilter: 500,
};

And the high res watcher:

const options = {
  enableHighAccuracy: true,
  timeout: 60e3,
  maximumAge: 10e3,
};

I have played around with the settings, but I can't see any difference in the output. Both watchers emits the exact same positions at the same time. I'm using the iOS simulator for the moment.

Questions:

Edit, the actual question is: Why do I get high frequent accurate gps positions even in "significant changes" mode. This mode is supposed to save battery if I have understood correctly.

Thanks!

Upvotes: 1

Views: 3843

Answers (1)

Michael Cheng
Michael Cheng

Reputation: 10501

The useSignificantChanges option is fairly new and only recently implemented, so you need to make sure that:

  1. You are using a version of React Native that supports it. Based on merge dates, looks to be v0.47+
  2. You are testing on an iOS version that can use it. The Github issue states that this is a new feature that impacts iOS 11, so I presume that you would need at least that version to see any differences.

Upvotes: 2

Related Questions