同时对2个或更多位置进行地理编码

时间:2016-02-08 10:04:31

标签: ios objective-c google-maps

我正在尝试从多个地址字符串中获取位置。

我在下面的代码中使用了单个字符串。

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

如何一次从多个地址字符串中获取两个或多个位置。也就是说,想要为每个单独的字符串设置单独的lat,并且在获得所有位置之后我需要运行其他一些代码。

请帮忙。在此先感谢。

2 个答案:

答案 0 :(得分:2)

请改用它 https://maps.googleapis.com/maps/api/geocode/json?address=%@&key=%@

将地址作为esc_add传递,并使用The Google Maps Geocoding API

创建一个google api密钥

还有一件事用“+”替换所有空格“”

示例https://maps.googleapis.com/maps/api/geocode/json?address=Neeru's + Emporio,Road + Number + 36,Venkatagiri,Hyderabad,Andhra + Pradesh,India& key = YOUR_API_KEY

它会正常工作

答案 1 :(得分:0)

使用apple的地理编码器有限制(例如批量请求)。有关详细信息,请参阅apple dev forum(苹果的答案)。您可以使用谷歌等其他服务(也有限制)或使用自己开放街道地图上的解决方案(您可以使用例如.xapi或overpass api)。

相关问题