Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Location Manager update frequency, iphone

I have a CLLocation manager called "myLocation".

myLocation = [[CLLocationManager alloc] init];
    myLocation.desiredAccuracy = kCLLocationAccuracyBestForNavigation ;
    myLocation.distanceFilter = 10 ;
    myLocation.delegate=self;



    locationEnabledBool = [CLLocationManager locationServicesEnabled];



    if (locationEnabledBool ==NO || ( [CLLocationManager  authorizationStatus] == kCLAuthorizationStatusDenied)) {

    //  LocationText.text = @"Location Service Disabled ";
        UIAlertView *locationAlert = [[UIAlertView alloc] initWithTitle:@"Location Service Disabled" 
                                                        message:@"To re-enable, please go to Settings and turn on Location Service for this app." 
                                                       delegate:nil 
                                              cancelButtonTitle:@"OK" 
                                              otherButtonTitles:nil];
        [locationAlert show];
        [locationAlert release];

    }

        [myLocation startUpdatingLocation];

and location update function is

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{

NSLog(@"old location is %f, %f ", oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
NSLog(@"new location is %f,%f",newLocation.coordinate.latitude, newLocation.coordinate.longitude );
}

Is there a way to find frequency of location manager update, and If it can be increased or decreased?

like image 416
alekhine Avatar asked Sep 12 '11 08:09

alekhine


2 Answers

Your location update starts only when you call the method [locationManager startUpdatingLocation].

You can control the frequency of the update using an NSTimer. Call the startUpdatingLocation method at regular intervals whenever you need a location update and then immediately call the stopUpdatingLocation method. The next time you will get a location update only at the interval you have set in the NSTimer.

like image 176
stack2012 Avatar answered Sep 21 '22 10:09

stack2012


For detecting even the slightest of movements, you need to set

myLocation.distanceFilter = kCLDistanceFilterNone ; 

But, please keep in mind,letting location manager to generate updates for even the slightest of movements can end up in lot of battery usage.

like image 43
vslifetracker Avatar answered Sep 22 '22 10:09

vslifetracker