ios - 为 GoogleMap objective-c 调用 API

标签 ios objective-c web-services google-maps

任何人都可以指导我在完成将 GoogleMaps 的 pod 安装到项目中的所有步骤后如何在 GoogleMap 中使用 place auto complete 吗?我对此一无所知,请有人帮助我!!!

最佳答案

希望你已经成功集成了 google pod

导入谷歌地图类

@import GoogleMaps;

添加委托(delegate)

<GMSAutocompleteViewControllerDelegate>

我的屏幕上有一个用于自动完成屏幕的按钮。 在按钮 IBAction 上写这段代码

GMSAutocompleteViewController *acController = [[GMSAutocompleteViewController alloc] init];
acController.delegate = self;
[self presentViewController:acController animated:YES completion:nil];

并实现 GMSAutocompleteViewControllerDelegate

- (void)viewController:(GMSAutocompleteViewController *)viewControllerdidAutocompleteWithPlace:(GMSPlace *)place {
[self dismissViewControllerAnimated:YES completion:nil];
  // Do something with the selected place.

  NSLog(@"Place name %@", place.name);
  NSLog(@"Place address %@", place.formattedAddress);
  NSLog(@"Place attributions %@", place.attributions.string);
}                           

- (void)viewController:(GMSAutocompleteViewController *)viewControllerdidFailAutocompleteWithError:(NSError *)error {
  [self dismissViewControllerAnimated:YES completion:nil];
  // TODO: handle the error.
  NSLog(@"Error: %@", [error description]);
}

// User canceled the operation.
- (void)wasCancelled:(GMSAutocompleteViewController *)viewController {
    [self dismissViewControllerAnimated:YES completion:nil];
}

// Turn the network activity indicator on and off again.
- (void)didRequestAutocompletePredictions:(GMSAutocompleteViewController*)viewController {
      [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
 }

 - (void)didUpdateAutocompletePredictions:(GMSAutocompleteViewController*)viewController {
     [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
 }

关于ios - 为 GoogleMap objective-c 调用 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38473443/

相关文章:

iphone - 如何防止 subview 的剪辑部分仍然发生触摸事件?

ios - 更新 UITabBarItem 中所选图像的前景色

objective-c - 如何将 Objective-C 中的阿拉伯语(Unicode 编码)转换为字节十六进制表示形式?

iphone - touches移出自身 View

asp.net - WCF 安全 - 我不明白的内容列表

ios - 在 iOS 中使用 UIPickerView 时遇到问题

IOS Notification实现设计技巧

java - 如何从返回android应用程序中的对象的android应用程序使用asmx web服务?

iphone - 使用 IP 地址、端口和凭据进行实时视频流监控

ios - 如何防止 Core Data 在 iOS 5 中重复?