我在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;
}
答案 0 :(得分:6)
启用了适用于IOS的Google Places API。
答案 1 :(得分:4)
2018年6月18日之后,谷歌限制了限额并更改了政策,您需要在此之后启用结算功能。
我已经启用了Google Places api和google map api,但仍然显示错误。
启用结算后的结算
答案 2 :(得分:0)
我遇到了同样的问题。当我返回并再次检查帐单帐户页面时,我注意到它没有列出我当前的工作项目名称。 添加我当前的项目后,它就可以工作。
确保您当前的项目已在“结算”页面中列出
答案 3 :(得分:0)
->确保更新至最新版本的Google Places Pod(不推荐使用GooglePlacepicker)
->启用Google地方信息API
->同时检查APIKey是否正确