CLLocationManager geocodeAddressString:inRegion无法约束区域(ios5)

问题描述 投票:7回答:1

我正在尝试使用iOS 5中的新CLLocationManager API进行(转发)地理编码,并且没有任何运气。

我正在根据当前位置指定一个区域,但它却在世界的另一边给我结果。

//CLLocation *currentloc is set to the current location when I get in here (<+37.78583400,-122.40641700>)
CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:[currentloc coordinate] radius:5000 /*meters*/ identifier:@"You are here"];
// Region is now: (identifier You are here) <+37.78583400,-122.40641700> radius 5000.00m

NSString *addressString = @"Citibank"; //for example
[geoCoder geocodeAddressString:addressString inRegion:region completionHandler:^(NSArray* placemarks, NSError* error){
    for (CLPlacemark* aPlacemark in placemarks)
    {                    // Process the placemark.
        NSLog(@"Got Placemark : %@", aPlacemark);     

    }
}];

而我得到的只是:

> 2011-12-14 15:50:49.882 [12377:12503] Got Placemark : Citibank, New
> Delhi, Delhi, India @ <+28.63470640,+77.22010140> +/- 100.00m, region
> (identifier <+28.63517750,+77.21878050> radius 154.35)
> <+28.63517750,+77.21878050> radius 154.35m
> 
> 2011-12-14 15:50:49.883[12377:12503] Got Placemark : CitiBank, Noida,
> Uttar Pradesh, India @ <+28.58157180,+77.32408380> +/- 100.00m, region
> (identifier <+28.58161950,+77.32315050> radius 154.41)
> <+28.58161950,+77.32315050> radius 154.41m
> 
> 2011-12-14 15:50:49.885 [12377:12503] Got Placemark : Citibank, New
> Delhi, Delhi, India @ <+28.53627320,+77.21128390> +/- 100.00m, region
> (identifier <+28.53630050,+77.21054050> radius 154.46)
> <+28.53630050,+77.21054050> radius 154.46m
> 
> ...

有任何想法吗:

  1. 我觉得我在新德里吗? (我认为答案是否定的 - 因为寻找带有相同inRegion的“All Star Donuts”让我进入了泰国
  2. 我在滥用“inRegion”吗?
  3. 这适用于任何人吗?因为如果它确实如此,它将是伟大的
iphone ios geocoding core-location
1个回答
0
投票

好的,答案。

  1. 不,它没有。它首先使用区域作为搜索的地方。来自API: 通过指定区域,您可以将返回的结果集划分给接近某个特定地理区域(通常是用户的当前位置)的位置的优先级。
  2. 一切都好。
  3. 对于请求“星巴克”它返回我 得到地标:Starbuck Dr,Sausalito CA 94965,美国@ <+ 37.86315000,-122.57986000> +/- 100.00m,地区(标识符<+ 37.86315000,-122.57986000>半径282.92)<+ 37.86315000,-122.57986000>半径282.92m
so seems like it works.

我的建议是检查从服务器返回的地区中心和地标中心之间的距离。

© www.soinside.com 2019 - 2024. All rights reserved.