ios - 地点选择器未加载

标签 ios google-places-api

当我加载地点选择器时,它最初会加载,但后来当它关闭时我无法选择任何地点

    func placePicker(_ viewController: GMSPlacePickerViewController, didPick place: GMSPlace) {
    print("Place name \(place.name)")
    print("Place address \(place.formattedAddress)")
    print("Place attributions \(place.attributions)")
    viewController.dismiss(animated: true, completion: nil)

}
func placePickerDidCancel(_ viewController: GMSPlacePickerViewController) {
    // Dismiss the place picker, as it cannot dismiss itself.
    viewController.dismiss(animated: true, completion: nil)

    print("No place selected")
}

enter image description here

最佳答案

几个月前,它很容易修复,

API key 与 Google map APIKey 相同

如果它没有解决您的解决方案,则需要注意一些事项,如here所述

首先,转到https://console.developers.google.com/apis/并确保 Google Places API 已启用。在左上角选择您的项目,然后在左侧选择库。然后,查找“Places API”并启用该 API。

enter image description here

enter image description here

其次,请确保您已启用结算帐户。为此,请转至 https://console.developers.google.com/billing/并继续创建帐户。确保您的项目也链接到此帐户。要链接帐户,请转到您的项目并从左上角的汉堡菜单中选择“计费”选项。

最后,如果您有应用程序限制,请确保您的 iOS 项目中的 bundle 标识符与您正在使用的 API key 相关联。转到 XCode 中的项目,单击“常规”选项卡,然后复制“ bundle 标识符”的值。然后,返回https://console.developers.google.com/apis/并确保您的项目被选中。然后,转到左侧的“凭据”选项卡。选择您的 key ,然后转到显示“接受来自带有这些 bundle 标识符之一的 iOS 应用程序的请求”的位置,并将该值粘贴到下面的文本框中。

如果您有 API 限制,请确保将 Places API 添加到您的可访问 API 列表中。

点击顶部的“重新生成 key ”,然后使用项目中“API key ”下方生成的新 key 。此过程最多可能需要 5 分钟才能生效。

enter image description here enter image description here

关于ios - 地点选择器未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56166158/

相关文章:

ios - 如何跟踪 iPhone 应用程序安装和引荐来源网址

google-maps-api-3 - 谷歌和推特从哪里获取城市、地区和州的政治边界?

google-maps - 如何为Google Places API启用CORS

iphone - 在iOS objective-c 中反向播放音频文件

ios - semaphore_wait_trap 阻塞 UI

ios - 在 UILabel 之后放置一个 UIImage

ios - Google Places 自动完成 Swift 3

python - 在 Google Places api 中搜索附近的 lat_lng (python)

android - Google Places-API statusCode = PLACES_API_ACCESS_NOT_CONFIGURED

ios - 在 Swift 的 UIScrollview 中面临问题