开发者

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 开发者_如何学Pythonon 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!! :)


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];


Download this example

this example will show you current lat long


You will need to call CLLocationManager (See Apple Documentation). - startUpdatingLocation and - stopUpdatingLocation are one of the main methods you will be using.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜