GMSReverseGeocodeResponse
包含
- (GMSReverseGeocodeResult *)firstResult;
其定义类似于:
@interface GMSReverseGeocodeResult : NSObject<NSCopying>
/** Returns the first line of the address. */
- (NSString *)addressLine1;
/** Returns the second line of the address. */
- (NSString *)addressLine2;
@end
有没有办法从这两个字符串中获取国家、ISO国家代码、州(administrative_area_1或对应的州)?该方法适用于所有国家和所有地址。
注意:我尝试执行了这段代码
[[GMSGeocoder geocoder] reverseGeocodeCoordinate:CLLocationCoordinate2DMake(40.4375, -3.6818) completionHandler:^(GMSReverseGeocodeResponse *resp, NSError *error)
{
NSLog( @"Error is %@", error) ;
NSLog( @"%@" , resp.firstResult.addressLine1 ) ;
NSLog( @"%@" , resp.firstResult.addressLine2 ) ;
} ] ;
但出于某些原因,处理程序从未被调用。我确实添加了应用程序密钥,还将iOS捆绑标识添加到了应用程序密钥中。控制台中未打印错误。我的意思是我不知道这些行的内容。
GMSGeocoder
现在通过GMSAddress
提供结构化地址,弃用了GMSReverseGeocodeResult
。”- Google Maps SDK for iOS Release Notes, Version 1.7, February 2014. - Pang