来自geocodeAddressString的意外结果

时间:2014-01-10 22:15:34

标签: ios7 clgeocoder

我的问题是,当addressTF.text有一个非常合理的地址字符串时,为什么poiCoordinate的纬度和经度属性会出现0,0,例如“1 Infinite Loop,Cupertino,CA 95014”?

//HomeViewController.m

@implementation HomeViewController

CLLocationCoordinate2D poiCoordinate;

-(void)performStringGeocode
{
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    [geocoder geocodeAddressString:_addressTF.text completionHandler:^(NSArray *placemarks, NSError *error)
    {
        if (error)
        {
            NSLog(@"Geocode failed with error: %@", error);
            return;
        }
    CLPlacemark *placemark = [placemarks firstObject]; //Line A
    poiCoordinate = placemark.location.coordinate;     //Line B
    }];
}

0 个答案:

没有答案