【发布时间】:2017-12-22 23:27:33
【问题描述】:
在我的应用程序中,我希望在 Objective-C 中使用 IOS 中的前向地理编码获得给定地址的确切 lattitude 和 longitude。
我在我的应用程序中使用了前向地理编码,但它没有给出确切的地址。这是我的正向地理编码代码
-(void)detectlocation:(NSString*)address
{
CLGeocoder *geocoder=[[CLGeocoder alloc]init];
[geocoder geocodeAddressString:address completionHandler:^(NSArray *placemarks, NSError *error)
{
if(!error)
{
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSLog(@"%f",placemark.location.coordinate.latitude);
NSLog(@"%f",placemark.location.coordinate.longitude);
self.latitude4=placemark.location.coordinate.latitude;
self.longitude4=placemark.location.coordinate.longitude;
NSLog(@"%@",[NSString stringWithFormat:@"%@",[placemark description]]);
}
}];
}
提前致谢
【问题讨论】:
标签: ios objective-c clgeocoder