Google Places iOS-无法加载搜索结果

Sha*_*hah 4 google-maps ios google-places-api gmsautocomplete

我在我的iOS项目中使用了Google Places API的GMSAutoCompleteViewController。

今天突然,我的GMSAutoCompleteViewController继续给我错误“无法加载搜索结果”。

我已经使用新的API密钥重新生成了我的API密钥。我已经尝试了所有方法,但是仍然有些方法不起作用。

我正在使用Objective-C。有人可以帮忙吗?

GMSAutocompleteViewController *acController = [[GMSAutocompleteViewController alloc] init];
    acController.delegate = self;
[self.navigationController pushViewController:acController animated:YES];
Run Code Online (Sandbox Code Playgroud)

委托方法

- (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);
    NSLog(@"Latitude = %.20f",place.coordinate.latitude);
    NSLog(@"Longitude = %.20f",place.coordinate.longitude);
    NSLog(@"Type = %@",place.types);
    NSLog(@"Place ID = %@",place.placeID);
    //[self dismissViewControllerAnimated:YES completion:nil];
    [self.navigationController popViewControllerAnimated:YES];

    /* Call and API in background to get the address according to the new LAT AND LONG as well
     Once get the address from there we can store the latitude and longitude in the cache
     if type of search is Postal code then we have to call another web service i.e. FIND ADDRESS to get the whole exact address */

    [self callWS_ConvertLatLongWithLatitude:[NSString stringWithFormat:@"%.20f",place.coordinate.latitude]
                               andLongitude:[NSString stringWithFormat:@"%.20f",place.coordinate.longitude]
                               inBackground:NO];

}

- (void)viewController:(GMSAutocompleteViewController *)viewController
didFailAutocompleteWithError:(NSError *)error {

    NSLog(@"error: %ld", [error code]);

    [self.navigationController popViewControllerAnimated:YES];

}

// User canceled the operation.
- (void)wasCancelled:(GMSAutocompleteViewController *)viewController {
    NSLog(@"Autocomplete was cancelled.");

    [self.navigationController popViewControllerAnimated:YES];
}

// 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;
}
Run Code Online (Sandbox Code Playgroud)

ans*_*son 6

确保启用了适用于IOS的Google Places API。

  1. 转到您的https://console.developers.google.com/apis/
  2. 选择“库”-“ iOS版Google Places API”
  3. 启用(蓝色按钮)

API密钥与Google Maps APIKey相同在此处输入图片说明

  • 面临同样的问题。每十次工作一次。无法理解该问题。 (4认同)
  • 它已经启用,有一段时间它返回数据,但是大多数时候没有数据 (2认同)

Rav*_*jha 5

在2018年6月18日之后,Google限制了该限制并更改了政策,您需要启用结算后才能使用。

我已经启用了Google Places api和google map api,但仍然显示错误。

启用结算后,其已解决