How to get distance from userLocation every 4-5 seconds

I do not use this for travel or the like. I have a few annotations and you need a trigger when the user is next to one of them, so I can warn the user.

DidUpdateToLocation seems to be called only once per runUpdating a Location call? At least when I have NSLog inside this method, I get only one line in the console. No, I do not go with iphone.

So: What is the right way to set up continuous monitoring of userLocation and get a โ€œcallbackโ€ (either after 3-4 seconds, or when the user has moved, say, 10 meters)?

+3
source share
1 answer

, , , :

locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; 
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
[locationManager startUpdatingLocation];

didUpdateToLocation :

- (void) locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*) oldLocation 
{
   // This will be called every time the device has any new location information. 
}

didUpdateToLocation . didUpdateToLocation, . , , distanceFilter desiredAccuracy, , .

kCLLocationAccuracyBest kCLLocationAccuracyNearestTenMeters .

+4

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


All Articles