gpt4 book ai didi

iphone - CLLocationManager 地理编码地址字符串 :inRegion not working to constrain region (ios5)

转载 作者:可可西里 更新时间:2023-11-01 03:35:14 25 4
gpt4 key购买 nike

我正在尝试使用 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. 这对任何人都有效吗?因为当它发生时会很棒

最佳答案

好的,答案。

<醇>
  • 不,不是。它只是使用区域作为首先搜索的地方。来自 API:

    Specifying a region lets you prioritize the returned set of results to locations that are close to some specific geographical area, which is typically the user’s current location.

  • 一切正常。

  • 对于请求“星巴克”,它返回我

    Got Placemark : Starbuck Dr, Sausalito CA 94965, United States @ <+37.86315000,-122.57986000> +/- 100.00m, region (identifier <+37.86315000,-122.57986000> radius 282.92) <+37.86315000,-122.57986000> radius 282.92m

  • 所以看起来它有效。

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

    关于iphone - CLLocationManager 地理编码地址字符串 :inRegion not working to constrain region (ios5),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8513623/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com