Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I've problem to obtain current location Longitude and Latitude in iOS 4.0 also tried in iOS 4.2 actually i want to draw route on my apps from current position to specific location, i tried many way in my apps but i can't get result

please reply anyone know about this.

Thanks!! :)

like image 621
Alpesh Patoliya Avatar asked Aug 29 '11 09:08

Alpesh Patoliya


2 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];
like image 132
Bill Burgess Avatar answered Sep 23 '22 13:09

Bill Burgess


Download this example

this example will show you current lat long

like image 23
Droid Avatar answered Sep 24 '22 13:09

Droid