我正在尝试从多个地址字符串中获取位置。
我使用下面的代码来表示单个字符串。
NSString *addressStr = @"Neeru'sEmporio,RoadNumber36,Venkatagiri,Hyderabad,AndhraPradesh,India"; //String after removing spaces
[[CLGeocoder new] geocodeAddressString:orgin completionHandler:^(NSArray *placemarks, NSError *error)
{
if(!error)
{
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSLog(@"%f",placemark.location.coordinate.latitude);
NSLog(@"%f",placemark.location.coordinate.longitude);
NSLog(@"%@",[NSString stringWithFormat:@"%@",[placemark description]]);
}
else
{
NSLog(@"There was a forward geocoding error\n%@",[error localizedDescription]);
}
}
];
如何一次从多个地址字符串获取两个或多个位置。即,想要每个单独的字符串都有单独的经纬度,并且在获取所有位置后我需要运行一些其他代码。
请帮忙。提前致谢。
最佳答案
用这个代替 https://maps.googleapis.com/maps/api/geocode/json?address=%@&key=%@
将地址作为 esc_add
传递,并使用 The Google Maps Geocoding API 创建 Google api key
还有一件事将所有空格“”替换为“+”
示例https://maps.googleapis.com/maps/api/geocode/json?address=Neeru 's+Emporio,路+号码+36,文卡塔吉里,海得拉巴,安得拉+邦,印度&key=YOUR_API_KEY
它会正常工作
关于ios - 同时对 2 个或更多位置进行地理编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35266847/