Google 地图 API 地点自动完成 componentRestrictions 限制

Google Maps API Places Autocomplete componentRestrictions Limit

为什么 componentRestrictions 被限制为 5。是否可以增加 Limit?我需要 8 个国家的自动完成功能。

是否有增加限制的解决方法?

You can do this by specifying up to 5 countries in the componentRestrictions field of the AutocompleteOptions.

https://developers.google.com/maps/documentation/javascript/releases#327

您可以在

找到原始功能请求中的说明

https://issuetracker.google.com/issues/35821685#comment236

根据 Google 工程团队

There is a limitation to this new feature: requests may be restricted up to 5 countries.

Please note that restricting to multiple countries comes with an increased latency. The limit of 5 countries is there to keep the latency increase in check.

所以,这个限制是为了控制自动完成服务的延迟增加。

也许您可以创建包含所有 8 个国家/地区的边界作为解决方法,并使用严格边界选项将自动完成限制为边界。

我希望这能澄清你的疑问!