How to get current longitude and latitude of location in iOS 4.0 / 4.2?

I have a problem getting my current location. Longitude and latitude in iOS 4.0 also tried in iOS 4.2, in fact, I want to draw a route in my applications from the current position to a certain place, I tried many ways in my applications, but I can not get the result

answer, does anyone know about this.

Thank!!:)

+5
source share
4 answers
CLLocationManager *lm = [[CLLocationManager alloc] init];
lm.delegate = self;
lm.desiredAccuracy = kCLLocationAccuracyBest;
lm.distanceFilter = kCLDistanceFilterNone; 
[lm startUpdatingLocation];

CLLocation *location = [lm location];

CLLocationCoordinate2D coord;
coord.longitude = location.coordinate.longitude;
coord.latitude = location.coordinate.latitude;
// or a one shot fill
coord = [location coordinate];
+16
source

Download this example.

this example will show you the current long length

+5
source

intuit/LocationManager GitHub. CLLocationManager .

+2

You will need to call the CLLocationManager (see Apple Documentation ). - startUpdatingLocationand - stopUpdatingLocationare one of the main methods that you will use.

0
source

All Articles