1

我正在使用 react-native-google-places 但我需要限制搜索 2 个或更多国家/地区,例如丹麦和美国。但是在 react-native-google-places 中,我唯一的选择是国家,它只接受一个国家。如何在不使用纬度和经度以及半径的情况下解决此问题?

RNGooglePlaces.openAutocompleteModal({
            country: 'us', // need to use 'us', 'dk' or somethink like ['us', 'dk']
            useOverlay: true
        })
        .then((place) => {
            console.log(place);
        })
        .catch(error => console.log(error.message));

4

2 回答 2

0

根据androidios上的底层原生 API, 您一次只能将搜索限制在一个国家/地区。不确定您的具体需求,但您可能可以查看react-native-google-places-autocomplete,它使用 Javascript API,您可以通过指定components 参数的多个国家/地区进行过滤

于 2018-09-24T12:37:01.543 回答
0

您可以使用 react-native-google-places-autocomplete 库,在此我们可以通过添加如下查询参数来限制多个国家/地区的结果:

查询={{ 键:'YOUR_API_KEY',语言:'en',组件:'country:us|country:ca',}}

于 2021-05-28T08:56:13.857 回答