代码改变世界

iphone-地理位置相关

2010-10-14 19:49  Tracy E  阅读(459)  评论(0编辑  收藏  举报

调用google map应用:

NSString *strUrl = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@",[[stationArr objectAtIndex:tag] _position]];

strUrl = [strUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSURL *url = [NSURL URLWithString:strUrl];

[[UIApplication sharedApplication] openURL:url];

 

获取当前位置的经纬度:

locationManager = [[CLLocationManager alloc] init];

[locationManager startUpdatingLocation];

 

CLLocation *location = [locationManager location];

CGFloat m_latitude = location.coordinate.latitude;

CGFloat m_longitude = location.coordinate.longitude;

 

[locationManager stopUpdatingHeading];