GooglePlaces iOS,无法加载搜索结果

时间:2017-01-23 18:38:28

标签: ios objective-c google-places-api

GooglePlaces GMSAutocompleteViewController停止搜索地点。 check the screenshot image

GMSPlacesClient键设置正确,工作正常。

如果您对此问题一无所知,请提供帮助。感谢。

2 个答案:

答案 0 :(得分:2)

您的Google地方密钥将过期或您插入了错误的密钥。请检查您的密钥

import <GoogleMaps/GoogleMaps.h>

#import "ViewController.h"

@interface ViewController ()<GMSAutocompleteViewControllerDelegate>

@end

@implementation ViewController

// TODO: Add a button to Main.storyboard to invoke onLaunchClicked:

// Present the autocomplete view controller when the button is pressed.
- (IBAction)onLaunchClicked:(id)sender {
  GMSAutocompleteViewController *acController = [[GMSAutocompleteViewController alloc] init];
  acController.delegate = self;
  [self presentViewController:acController animated:YES completion:nil];
}

// Handle the user's selection.
- (void)viewController:(GMSAutocompleteViewController *)viewController
    didAutocompleteWithPlace:(GMSPlace *)place {
    // Do something with the selected place.
    NSLog(@"Place name %@", place.name);
    NSLog(@"Place address %@", place.formattedAddress);
    NSLog(@"Place attributions %@", place.attributions.string);
    [self dismissViewControllerAnimated:YES completion:nil];
}

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

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

@end

访问 https://developers.google.com/places/ios-api/

答案 1 :(得分:0)

我也面临同样的问题。 我在添加了信用卡的帐户上制作了Google API密钥。但是该键无法正常工作。 为了解决此问题,请更新您的广告连播