【问题标题】:Returning Multiple Placemarks When Geocoding Address String iOS 6地理编码地址字符串iOS 6时返回多个地标
【发布时间】:2012-12-15 18:58:56
【问题描述】:

这是我在堆栈上的第一篇文章。我是 iOS 开发新手,需要地理编码方面的帮助。

特别是,根据 Apple 的文档:“返回的地标对象的数量在很大程度上取决于所提供信息的特异性。因此,提供街道、城市、省和国家/地区信息比返回单个地址的可能性更大。只是街道和城市信息。”

因此,在提供地址字符串时宽泛,应该(理论上)返回多个结果。

例子:

-(void)geocodeAddress {
CLGeocoder *geocoder = [[CLGeocoder alloc]init];
[geocoder geocodeAddressString:@"DMV, San Francisco, CA" completionHandler:^(NSArray *placemarks, NSError *error) {
    if (!error) {
        NSLog(@"Found: %i", [placemarks count]);
        for (CLPlacemark *placemark in placemarks) {
            CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(placemark.location.coordinate.latitude, placemark.location.coordinate.longitude);
            MapAnnotation *annotation = [MapAnnotation mapAnnotationWithCoordinate:coordinate title:@"DMV" subtitle:@"Great service?"];
            [self.mapView addAnnotation:annotation];
        }
    } else {
        NSLog(@"Error code: %i", [error code]);
    }
}];

}

让我有点困惑的是,无论我的“搜索”范围有多大(星巴克,DMV,与 1234 S 312th Place,City,State),我总是会返回一个位置。

那么,我的问题是,有没有办法为特定搜索返回多个结果?

【问题讨论】:

  • 嗨,你有没有找到答案?我得到同样的东西..
  • 如果有人只需要一个示例地址来传递 CLGeocoder,请尝试传递返回多个地址的字符串“Springfield”。这是我曾经测试过的,因为我也很难尝试使用街道名称来获取多个地址。

标签: iphone objective-c ios6 ios6-maps


【解决方案1】:

看起来 CLGeocoder 在这个阶段非常有限。在更新解决此问题之前,您最好的选择是使用其他服务(例如 Google Maps Geocoding API)。请注意,您只能将 Google 地理编码与 google 地图一起使用:https://developers.google.com/maps/documentation/geocoding/

【讨论】:

    猜你喜欢
    • 2015-12-08
    • 1970-01-01
    • 2016-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多