-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Geolocation] Expose option for distance filtering on location updates. #5563
Conversation
By analyzing the blame information on this pull request, we identified @mkonicek, @nicklockwood and @sahrens to be potential reviewers. |
@christopherdro my understanding is that the distance filter is separate from the idea of "accuracy", but is instead related to minimum distance for a "change" in location to have occurred. It seems that in this case, using an arbitrary double value should be just fine. |
@lelandrichardson That's correct the idea of accuracy and distance are different. Here is what docs say about distance filter.
I figured it would be just fine but with iOS you just never know. |
It seems to me like using a double should work fine 👍 |
+1 confirmed working |
Upon further testing, I believe there is an edge case where on Android 0 is treated as no distance filter but on iOS actually does filter results (perhaps 0 -> infinity) To make this more intuitive we could set 0 to |
@rt2xx that makes sense to me. |
ddb2aa3
to
10affb9
Compare
@christopherdro updated the pull request. |
@rt2zz Nice catch! Entering 0 as an option would still default This should now be working properly with the updated nested ternary operator. |
10affb9
to
c4b3109
Compare
@christopherdro updated the pull request. |
abace86
to
13aca33
Compare
Possible solution for #1240 |
13aca33
to
32536d1
Compare
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1701598750054106/int_phab to review. |
109036b
Summary: My original implementation involved creating a `RCT_ENUM_CONVERTER` with `CLLocationAccuracy` on iOS and a Hashmap on Android that would convert `string` values to `doubles` for distance filtering. I got this to work just fine but realized that I made things more complicated than they needed to be and simplified everything by just have the option be a decimal value (in meters) that works both for iOS and Android. The only thing i'm not sure about is if we can set arbitrary values for CLLocationManager's distance filter. nicklockwood Any idea? Closes facebook#5563 Reviewed By: svcscm Differential Revision: D2908250 Pulled By: nicklockwood fb-gh-sync-id: d83c12b3ce7c343f413749a2cd614b3bf04d6750
@@ -128,7 +134,7 @@ - (void)beginLocationUpdates | |||
{ | |||
if (!_locationManager) { | |||
_locationManager = [CLLocationManager new]; | |||
_locationManager.distanceFilter = RCT_DEFAULT_LOCATION_ACCURACY; | |||
_locationManager.distanceFilter = _observerOptions.distanceFilter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@christopherdro should we move _locationManager.distanceFilter = _observerOptions.distanceFilter
outside of the if (!_locationManager)
so this could be changed when stoping and watching the location again? Also it seems that beginLocationUpdatesWithDesiredAccuracy
is called from getCurrentPosition
and it is not initialized from beginLocationUpdatesWithDesiredAccuracy
would this be an issue if the value is nil or just be a noop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change was made by @nicklockwood after he accepted my PR.
I'm not quite sure I understand the issue with beginLocationUpdatesWIthDesiredAccuracy
. Could you possible give an example of what the issue is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind there is a fix 49b2805
Update: actually this was for desiredAccuracy
is distanceFilter working properly now. |
yes |
My original implementation involved creating a
RCT_ENUM_CONVERTER
withCLLocationAccuracy
on iOS and a Hashmap on Android that would convertstring
values todoubles
for distance filtering.I got this to work just fine but realized that I made things more complicated than they needed to be and simplified everything by just having the option be a decimal value (in meters) that works both for iOS and Android.
The only thing i'm not sure about is if we can set arbitrary values for CLLocationManager's distance filter.
@nicklockwood Any idea?