我正在尝试使用CLLocationCoordinate2D获取用户的当前位置。我想要的格式值如下:使用CLLocationCoordinate2D获取当前位置
CLLocationCoordinate2D start = {-28.078694,153.382844};
所以,我可以使用他们喜欢以下内容:
NSString *urlAddress = [NSString
stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f",
start.latitude, start.longitude,
destination.latitude, destination.longitude];
我用
CLLocation *location = [[CLLocation alloc]init ];
CLLocationDegrees currentLatitude = location.coordinate.latitude;
CLLocationDegrees currentLongitude = location.coordinate.longitude;
获取当前纬度&长。
但是,当我尝试测试时,我得到了0.000。我正在测试iPhone 4s。
如果有任何示例代码,它会很好。
您是否使用了'MKMapView'? – 2012-03-14 05:27:56
你怎么得到你的坐标?添加迄今为止尝试的代码。 – deanWombourne 2012-03-14 05:28:00
我正在使用CLLocation * location = [[CLLocation alloc] init]; CLLocationDegrees currentLatitude = location.coordinate.latitude; CLLocationDegrees currentLongitude = location.coordinate.longitude; – iOSDev 2012-03-14 05:30:03