You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

新版Google Places API地点自动补全:国家限制及多类型参数问题

新版Google Places Autocomplete 国家限制与多类型参数设置

1. 限制响应结果到特定国家

新版API用regionCode参数替代旧版的components=country:,参数值采用ISO 3166-1 alpha-2格式的国家代码(比如印度对应in),直接将该参数加入请求即可实现国家范围限制。

2. 给includedPrimaryTypes传入多个值

有两种方式可以传入多个类型值:

  • 重复声明includedPrimaryTypes参数,每个参数对应一个类型
  • 用逗号分隔多个类型值,放在同一个includedPrimaryTypes参数中

整合后的完整请求示例

方式一(重复参数):

https://places.googleapis.com/v1/places:autocomplete
?key=<key>
&fields=suggestions.placePrediction.structuredFormat.mainText.text
&input=Karn
&includedPrimaryTypes=regions
&includedPrimaryTypes=locality
&regionCode=in

方式二(逗号分隔):

https://places.googleapis.com/v1/places:autocomplete
?key=<key>
&fields=suggestions.placePrediction.structuredFormat.mainText.text
&input=Karn
&includedPrimaryTypes=regions,locality
&regionCode=in

内容的提问来源于stack exchange,提问作者Akhil

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 04:41:00