OGeek|极客世界-中国程序员成长平台

标题: ios - 同时对 2 个或多个位置进行地理编码 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 18:27
标题: ios - 同时对 2 个或多个位置进行地理编码

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

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

NSString *addressStr = @"Neeru'sEmporio,RoadNumber36,Venkatagiri,Hyderabad,AndhraPradesh,India";  //String after removing spaces

    [[CLGeocoder new] geocodeAddressStringrgin 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 long,并且在获得所有位置后,我需要运行一些其他代码。

请帮忙。提前致谢。



Best Answer-推荐答案


改用这个 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,Road+Number+36,Venkatagiri,Hyderabad,Andhra+Pradesh,India&key=YOUR_API_KEY

它会正常工作

关于ios - 同时对 2 个或多个位置进行地理编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35266847/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4