我知道可以将地点限制在 1 个国家/地区:
componentRestrictions: {country: "fr"}
但是有没有办法限制像[“fr”,“be”]这样的N个国家?
最佳答案
componentRestrictions 实际上最多可以处理 5 个国家/地区,只需将国家/地区代码附加到具有 5 个元素的数组即可。
{ country: ["ch","at","fr","gr","mx"] }
Google 本身表示:“-componentRestrictions
可用于将结果限制为特定组。目前,您可以使用 componentRestrictions
过滤最多 5 个国家/地区。国家/地区必须作为两个字符、ISO 3166-1 Alpha-2 兼容的国家/地区代码传递。多个国家/地区必须作为国家/地区代码列表传递。 (查找:https://developers.google.com/maps/documentation/javascript/places-autocomplete)
Note: Question was already answered here: Need multiple country componentRestrictions in Google Places Autocomplete
关于javascript - 如何将谷歌自动完成地点限制为N个国家?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58889122/