我在我的iOS项目中使用来自Google Places API的GMSAutoCompleteViewController。
突然之间,我的GMSAutoCompleteViewController一直给我提示“无法加载搜索结果”的错误。
我已经使用新的API密钥重新生成了API密钥。我已经尝试了所有的方法,但仍然有一些方法不起作用。
我正在使用Objective-C。有人能帮上忙吗?
代码
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;
}发布于 2017-11-28 22:17:04
确保Google Places API for IOS已启用。
转到您的https://console.developers.google.com/apis/
与谷歌地图APIKey相同的API密钥

发布于 2019-02-19 17:38:34
在2018年6月18日之后,谷歌已经限制了限制并改变了策略,之后您需要启用计费,之后就可以工作了。
我已经启用了google places api和google map api,但仍然显示错误。
启用计费后,其解析
发布于 2019-06-07 05:58:33
我也面临着同样的问题。当我返回并再次检查帐单帐户页面时,我注意到它没有列出我当前正在工作的项目名称。一旦我添加了我当前的项目,它就起作用了。
确保您当前的项目列在帐单页面中
https://stackoverflow.com/questions/45855212
复制相似问题