小编sna*_*had的帖子

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

我正在尝试使用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, …
Run Code Online (Sandbox Code Playgroud)

iphone geocoding core-location ios

7
推荐指数
1
解决办法
6509
查看次数

标签 统计

core-location ×1

geocoding ×1

ios ×1

iphone ×1