sna*_*had 7 iphone geocoding core-location ios
我正在尝试使用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);
}
}];
Run Code Online (Sandbox Code Playgroud)
而我得到的只是:
> 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
>
> ...
Run Code Online (Sandbox Code Playgroud)
有任何想法吗:
我觉得我在新德里吗?(我认为答案是否定的 - 因为寻找带有相同inRegion的"All Star Donuts"让我进入了泰国
我在滥用"inRegion"吗?
这适用于任何人吗?因为如果它确实如此,它将是伟大的
好的,答案。
\n\n不,事实并非如此。它只是使用区域作为首先搜索的位置。来自 API:
\n\n\n通过指定区域,您可以将返回的结果集优先发送到靠近某个特定地理区域的位置,该地理区域通常是 user\xe2\x80\x99s 当前位置。
\n
一切都好。
\n获取地标:Starbuck Dr, Sausalito CA 94965,美国 @ <+37.86315000,-122.57986000> +/- 100.00m,区域(标识符 <+37.86315000,-122.57986000> 半径 282.92)<+37.86315000,-122。 57986000>半径282.92m
我的建议是检查您所在区域的中心与从服务器返回的地标中心之间的距离。
\n| 归档时间: |
|
| 查看次数: |
6509 次 |
| 最近记录: |