The distanceFilter property of the CLLocationManager object does not work correctly

I am using CLLocationManager in my application. I use the following code to initialize CLLocationManger.

self.locationManager = [[CLLocationManager alloc] init]; [self.locationManager setDelegate:self]; [self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [self.locationManager setDistanceFilter:10.0]; [self.locationManager startUpdatingLocation]; 

I set distanceFilter as 10.0 meters. Now I do not move my device (it is still in one place). but after that the delegate of CLLocationManger is automatically called.

 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { NSLog(@"Locations : %@", locations); } 

I want to get a new location if my device moves 10 meters, otherwise not.

So pls tell me how to use the distanceFilter property and get a new location.

+4
source share
1 answer

This is how GPS works, you stand still, sitting on a table by the window with a usually terrible GPS signal.

GPS does not know that you are not moving, especially when the signal is poor, it looks like you have moved. Therefore you receive an event. If you want to do it better, then you have to filter yourself and not rely on the apple distance filter.

This may work better for your special application.

+1
source

Source: https://habr.com/ru/post/1500461/


All Articles