Sukeshj
Sukeshj

Reputation: 1503

how to get current latitude & longitude

How to get current latitude & longitude without

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

} 

using this method

and if i used this function , how much distance i have to travel.... so that this method will be called by corelocation framework or can i call this function programmatic ....

Upvotes: 4

Views: 4158

Answers (2)

adedoy
adedoy

Reputation: 2273

Note that when you try to get the values while using a simulator and do:

nsLog(locationManager.location.coordinate.latitude); // it will give you zero

And if you use the mapkit to get the lat and long it will give you the coordinates of apple main office (If im not mistaken).

I thought that it take so much time before it actually gets your location but when I try to run it in the actual device it prompts the allow device to get current location immediately.

Upvotes: 1

Codebeef
Codebeef

Reputation: 44036

The CLLocationManager is the interface you must use in order to get information about the location of the device.

You can initialise and begin getting location updates whenever you like. The CLLocationManager will notify your delegate whenever a new location is received.

locationManager = [[CLLocationManager alloc] init]; 
locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
locationManager.distanceFilter = DISTANCE_FILTER_VALUE;
locationManager.delegate = self; 
[locationManager startUpdatingLocation];

Upvotes: 6

Related Questions