GMSAutocompleteViewController 仅显示 5 个结果

GMSAutocompleteViewController showing only 5 results

我在我的应用程序中集成了 GMSAutocompleteViewController

let autocompleteController = GMSAutocompleteViewController()
autocompleteController.delegate = self
let filter = GMSAutocompleteFilter()
filter.type = .address
autocompleteController.autocompleteFilter = filter

// Display the autocomplete view controller.
present(autocompleteController, animated: true, completion: nil)    

这总是只显示 5 个结果。此外,行为似乎有点奇怪。起初当我在搜索中写 J 时,显示了 5 个结果。在编写更多文本并删除这些文本以再次将搜索文本设置为 J 后,我得到 - 无法加载结果。然后结果永远不会显示,除非我重新启动我的应用程序。
我在 Android 中使用 AutocompleteSupportFragment 尝试了相同的实现,并且效果很好。在看到 Ravi's answer 和其他一些人之后,我早些时候想知道。 但如果启用计费是解决方案,为什么在 Android 中没有启用计费 也能正常工作?

我假设您已启用 Google Places API,并且您在 Google Developer Console 下对该项目没有应用程序限制。说有Google页关于APIs and billing

  1. Android 和 iOS 地点 API 可能不同,因此对于某些 API,您可能需要启用计费:

    Some APIs allow free usage up to a courtesy usage limit, and in some cases this free limit is increased when you enable billing.

  2. 也许在您的 Android 应用程序中,您正在使用一个 API 链接到一个启用了计费的项目,并且对于您的 iOS 应用程序,您正在使用一个 API 链接到另一个未启用计费的项目。

    Billing is enabled at the project level, not the API level. If you enable billing for a project, then every billable API in that project is billed, based on the project's usage. All usage in a project is billed using the payment method that you specify, and you can change to a different method at any time. You cannot selectively enable billing for some APIs but not others; when you enable billing for a project, it applies to all the APIs that you used within that project, even if the API is currently disabled.

可能与您在 Android 应用程序项目中使用的 Places SDK 版本有关,如果您要与更新后的 APIs 交谈,它的一些内部功能可能会受到影响需要启用或不启用计费的版本。检查 Migrating to the New Places SDK Client 中所述的信息以了解此假设。

最后,正如 Google 在 Android 的 Places SDK、iOS 的 Places SDK、API 中的大量文档所述,它们都有一个红色每篇文章开头的警告说在每个项目中你应该启用计费。如果我之前的所有陈述都失败了,这可能意味着他们在 users/projects 的不同批次中应用了计费规则和 APIs 功能限制,因此您的 android 应用程序项目可能已经失败在尚未推出以强制启用计费选项的批次中。

我遇到了类似的问题。正在尝试从 Google 实施新地点 API 以替换旧 SDK 的地点选择器。每天一两次成功调用后,我总是开始收到以下错误:

An error occurred: The operation couldn’t be completed. Operation failed due to exceeding the quota usage limit. See the usage limits guide (https://developers.google.com/places/ios-sdk/usage) for information on usage limits and how to request a higher limit.

我在控制台中启用了 Places API,并且还启用了使用有效信用卡的计费功能。仍然收到此错误。

解决方案是从 Google 云平台为 iOS 启用 Maps SDK。之后,我对请求没有限制,每次都能得到结果。希望对某人有所帮助。