Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 288
python Avatar asked Jun 26 '12 14:06

python


People also ask

How do you reset geolocation on iPhone?

If you would like to reset all of your location settings to the factory default, go to Settings > General > Reset and tap Reset Location & Privacy. When your location and privacy settings are reset, apps will stop using your location until you grant them permission.


1 Answers

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

[manager stopUpdatingLocation];
like image 87
shabbirv Avatar answered Oct 21 '22 09:10

shabbirv