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

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

如何一次从多个地址字符串获取两个或多个位置。即,想要每个单独的字符串都有单独的经纬度,并且在获取所有位置后我需要运行一些其他代码。

请帮忙。提前致谢。

最佳答案

用这个代替 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/

相关文章:

php - 更新 Google map 上的位置 - API

ios - Objective-c:自定义键盘/输入 View 上的 Siri

ios - PKPaymentAuthorizationViewController 在 iOS 8.4 上意外崩溃

ios - 与 iOS 应用程序的 Flurry 集成导致链接错误

iphone - UIActivityIndi​​catorView,在当前 View 上下载图片时显示

ios - 具有返回零高度的裁剪属性的 CTFramesetterSuggestFrameSizeWithConstraints

javascript - 使用Google Places API时出错。我该怎么办?

javascript - 一次只打开一个信息窗口

ios - 将数据从模态转场传递给父级

ios - Swift - 如何获取字典的最后一个键