我正在使用 GoogleMaps 和 GooglePlaces API,但我总是遇到同样的错误。
“操作无法完成。Places API 库中发生内部错误。如果您认为此错误代表错误,请使用我们社区和支持页面 (https://developers.google.com/places/support) 上的说明提交报告”
我尝试运行 pod try GoogleMaps,当我启动 de project 时,加载了任何 map ,只有一个具有不同选项的 tableView。
这是我的代码,我只想获取用户位置:
-(IBAction)getCurrentPlace:(UIButton *)sender {
[placesClient currentPlaceWithCallback:^(GMSPlaceLikelihoodList *placeLikelihoodList, NSError *error){
if (error != nil) {
NSLog(@"Pick Place error %@", [error localizedDescription]);
return;
}
self.nameLabel.text = @"No current place";
self.addressLabel.text = @"";
if (placeLikelihoodList != nil) {
GMSPlace *place = [[[placeLikelihoodList likelihoods] firstObject] place];
if (place != nil) {
self.nameLabel.text = place.name;
self.addressLabel.text = [[place.formattedAddress componentsSeparatedByString:@", "]
componentsJoinedByString:@"\n"];
}
}
}];
}
我在 didFinishLaunchingWithOptions 中导入了 mi APIKEY
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[GMSServices provideAPIKey:@"MY_APIKEY"];
return YES;
}
这是我的 Podfile
platform :ios, '7.0'
source 'https://github.com/CocoaPods/Specs.git'
target ‘googlePlace’ do
pod 'GoogleMaps'
pod 'GooglePlaces'
end
最后,我的 apikey 在 Google 控制台中配置到 iOS 应用程序。
有什么问题??
最佳答案
您的 API key 似乎无效或超出配额。
您能检查一下您是否将正确的 API key 传递给了 GMSPlacesClient.provideAPIKey(_:)。
如果您确定传递的是正确的 API key ,请检查 Google API 控制台 (https://console.developers.google.com/) 以确保您没有超出每日配额限制。
关于google-maps - Places API 库中发生内部错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40018588/