我看过一些文章,解释了如何在javascript/react中为google places自动完成设置多个国家/地区:componentRestrictions: {country: ["gb", "fr"]}
但是对于react-native GooglePlacesAutocomplete,建议将组件选项放在查询中。不确定我们是否可以通过多个国家...我尝试在这里传递一个数组,但失败了,因为它看起来只需要一个包含一个国家代码的字符串。会很感谢你的帮助。
<GooglePlacesAutocomplete
placeholder={placeholder}
listViewDisplayed={true}
fetchDetails={true}
textInputProps={{
borderColor: color,
fontSize: 18,
borderWidth: 1,
borderRadius: 4,
flex: 1,
padding: 7
}}
onPress={(data, details = null) => {
console.log(data, details)
}}
query={{
key: googleApiKey,
language: "en",
components: "country:gb",
types: types ? types : null
}}
/>发布于 2021-05-24 21:18:19
您可以使用类似于components: "country:gb|country:us"的组件限制
请参阅下面的完整代码示例
<GooglePlacesAutocomplete
placeholder={placeholder}
listViewDisplayed={true}
fetchDetails={true}
textInputProps={{
borderColor: color,
fontSize: 18,
borderWidth: 1,
borderRadius: 4,
flex: 1,
padding: 7
}}
onPress={(data, details = null) => {
console.log(data, details)
}}
query={{
key: googleApiKey,
language: "en",
components: "country:gb|country:us",
types: types ? types : null
}}
/>https://stackoverflow.com/questions/67668040
复制相似问题