Google Places iOS-无法加载搜索结果 [英] Google Places iOS - Can't load search result

查看:143
本文介绍了Google Places iOS-无法加载搜索结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过iOS项目中的Google Places API使用GMSAutoCompleteViewController.

I am using GMSAutoCompleteViewController from Google Places API in my iOS Project.

今天突然,我的GMSAutoCompleteViewController不断给我错误无法加载搜索结果".

Suddenly today my GMSAutoCompleteViewController keeps on giving me error "Can't load Search Results".

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

I have regenerated my API Key using fresh one. I have tried everything, but still some how it does not work.

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

I am using Objective-C. Can anyone help ?

代码

GMSAutocompleteViewController *acController = [[GMSAutocompleteViewController alloc] init];
    acController.delegate = self;
[self.navigationController pushViewController:acController animated:YES];

委托方法

- (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;
}

推荐答案

2018年6月18日之后,谷歌限制了该限制并更改了政策,您需要在此之后启用结算功能.

After 18th June 2018 , google have restrict the limit and changed the policy,you need to enable billing after then it will be work.

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

I was already enabled the google places api and google map api but still it was showing the error .

启用结算后,结算

这篇关于Google Places iOS-无法加载搜索结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆