iphone - How to getDistance from userLocation every 4-5 seconds -
I'm not using it for driving directions or similar. I have some annotations and want to trigger one when the user is around any one of them, so I can alert the user.
It seems that updatolocation is only called once per the startupdating location call? At least when I do NSLog within that system, I only get a line in the console, but I'm not roaming with the iPhone.
So: What is the correct way to establish constant monitoring of user space and receive "callback" (either when 3-4 seconds have passed or 10 meters when the user has moved) ?
As you probably know, this is the code to get started and start the location manager:
locationManager = [[CLLocationManager alloc] init]; LocationManager.delegate = self; LocationManager.distanceFilter = kCLDistanceFilterNone; LocationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; [LocationManager startUpdatingLocation]; Implement
and didUpdateToLocation as follows:
- (zero) Location Manager: Manager (CLLocationManager *) Location: New location from place (CLLocation *): (CLLocation *) oldLocation {// Every time the device has a new location information. }
will update the system to didUpdateToLocation
if every location is updated, if the change in the system is not detected in the didUpdateToLocation
If not, then he will not be invited to do whatever you can to set the Distance filter
and desired sophistication
, for example I did to give you the highest accuracy.
Update
Use kCLLocationAccuracyBest kCLLocationAccuracyNearestTenMeters for more accuracy.
Comments
Post a Comment