相关疑难解决方法(0)

如何从reverseGeocodeCoordinate获得国家,州,城市?

GMSReverseGeocodeResponse 包含

- (GMSReverseGeocodeResult *)firstResult;
Run Code Online (Sandbox Code Playgroud)

其定义如下:

@interface GMSReverseGeocodeResult : NSObject<NSCopying>

/** Returns the first line of the address. */
- (NSString *)addressLine1;

/** Returns the second line of the address. */
- (NSString *)addressLine2;

@end
Run Code Online (Sandbox Code Playgroud)

有没有办法从这两个字符串中获取国家,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 ) ;
 } ] ;
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,处理程序从未被调用过.我确实添加了应用密钥,并且还将iOS捆绑包ID添加到了应用密钥.控制台中未打印错误.有了这个,我的意思是我不知道线条的内容.

reverse-geocoding ios google-maps-sdk-ios

24
推荐指数
2
解决办法
3万
查看次数