python
python

Reputation: 1427

How to get current geo points only once in iphone?

I am using following code in viewDidLoad method

 CLLocationManager *locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
    locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation; 
    [locationManager startUpdatingLocation];

Then below method is called continuously when location changed.

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

But I want current geo points only once. Is there any method which gives you directly current geo points? I want to calculate distance between current geo points and other location when I click some button. please help me if any one knows.

Upvotes: 6

Views: 2726

Answers (1)

shabbirv
shabbirv

Reputation: 9098

In - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation you can call

[manager stopUpdatingLocation];

Upvotes: 6

Related Questions