ios - objective-c 谷歌地图委托(delegate)方法 reverseGeocodeCoordinate 方法

标签 ios objective-c google-maps geocoding reverse-geocoding

我不确定这是否是谷歌地图的新功能,但我认为这个版本的 iOS 版谷歌地图似乎已经有了反向地理编码方法……我真的不知道如何使用。 In their documentation page ,在 Camera Position 部分下,它们有一个功能,但它看起来不像是 SDK 附带的功能......或者这里可能有一些我不明白的地方。有人可以帮忙吗?这是 XCode 中出现的函数:

- (void)reverseGeocodeCoordinate:(CLLocationCoordinate2D)coordinate 
    completionHandler:(GMSReverseGeocodeCallback)handler{}

如果我的坐标在一个数组中,我该如何使用它?我如何获得地址和国家以及所有可能的结果?

顺便说一句,这就是他们所拥有的......它如何比较:

- (void)mapView:(GMSMapView *)mapView
idleAtCameraPosition:(GMSCameraPosition *)cameraPosition {
id handler = ^(GMSReverseGeocodeResponse *response, NSError *error) {
if (error == nil) {
  GMSReverseGeocodeResult *result = response.firstResult;
  GMSMarker *marker = [GMSMarker markerWithPosition:cameraPosition.target];
  marker.title = result.addressLine1;
  marker.snippet = result.addressLine2;
  marker.map = mapView;
}
};
[geocoder_ reverseGeocodeCoordinate:cameraPosition.target completionHandler:handler];
}

最佳答案

你可以试试这段代码

[[GMSGeocoder geocoder]reverseGeocodeCoordinate:CLLocationCoordinate2DMake(latitude, longitude)
completionHandler:^(GMSReverseGeocodeResponse * response, NSError *error){
    for(GMSReverseGeocodeResult *result in response.results){
        NSLog(@"addressLine1:%@", result.addressLine1);
        NSLog(@"addressLine2:%@", result.addressLine2);
    } 
}];

关于ios - objective-c 谷歌地图委托(delegate)方法 reverseGeocodeCoordinate 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22583240/

相关文章:

ios - 如何使用 4x4 矩阵变换或欧拉角旋转 3d 矢量?

ios - 我想在我的 ios 项目中识别 iphone 版本

google-maps - 如何在 Flutter 中为 Google Maps Marker 添加动画?

ios - 在 IOS 的文本字段中自动完成 Google Places

javascript - Mobile Safari 中的 Google Maps v3 InfoBox 事件传播

ios - 如何更改 iPhone 应用程序中状态栏的颜色?

android - Microsoft Cortana API SDK 适用于 iOS 和 Android 吗?

ios - 为什么自动布局忽略了一些约束?

iphone - 写入 plist 字典中的字符串

Iphone - 从 viewController 之外的另一个类调用动画到 View