我想限制我只搜索我所在城市的地方,任何帮助将不胜感激
我正在使用 => FaridSafi/react-native-google-places-autocomplete
谢谢
我想限制我只搜索我所在城市的地方,任何帮助将不胜感激
我正在使用 => FaridSafi/react-native-google-places-autocomplete
谢谢
<GooglePlacesAutocomplete
ref={ref}
currentLocation={true}
placeholder="Enter Location"
minLength={2}
autoFocus={false}
returnKeyType={'default'}
placeholderTextColor="black"
fetchDetails={true}
enablePoweredByContainer={false}
query={{
key: 'Your API key',
language: 'en',
types: '(cities)', <=== use this to only show country cities
components: 'country:pk', , <=== use this to restrict to country
}}
filterReverseGeocodingByTypes={[
'locality',
'administrative_area_level_1',
]}
GooglePlacesSearchQuery={{
rankby: 'distance',
}}
nearbyPlacesAPI="GooglePlacesSearch"
styles={{
textInputContainer: styles.textInputContainer,
description: {
fontWeight: 'bold',
},
textInput: styles.textInputAutoPlace,
}}
/>
在你的代码中添加这个
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: "API KEY",
language: "en", // language of the results
location: "-33.865143, 151.209900",
radius: "100000", //100 km
components: "country:au", // country name
strictbounds: true,
}}