react-native-google-autocomplete
react-native-google-autocomplete copied to clipboard
Restrict Autocomplete locationResults
Thanks for this package is awesome.
Is there any way to restrict the locationResults according to a specified location and using the radius prop?
Thank you :)
For a location you can example use the restrict by country here https://github.com/EQuimper/react-native-google-autocomplete#restrict-by-country
Is Nearby Search available? https://developers.google.com/places/web-service/search#PlaceSearchRequests
Hi @EQuimper , can you explain how to use location and radius please? i tried to add it in <GoogleAutoComplete />, <TexInput /> and <LocationResultItem /> but the locationResults aren't filtered any ways.
hope you'll find time to answer me, best regards
my code below :
<GoogleAutoComplete
apiKey="*****"
debounce={500}
predefinedPlaces={notLocatedPlace}
minLength={4}
language="fr"
components="country:fr"
location={{lat:45.526298,lng: 4.873333}}
radius={"20000"}
>
{({
handleTextChange,
locationResults,
fetchDetails,
isSearching,
inputValue,
clearSearchs,
location,
radius,
}) => (
<React.Fragment>
{console.log('locationResults', locationResults)}
<View
style={styles.adressContainer}
// style={{flexDirection:"row", justifyContent:"center", alignItems:"center"}}
>
<TextInput
underlineColorAndroid="#dfdfdf"
placeholder="Rechercher une adresse"
onChangeText={handleTextChange}
value={inputValue}
style={styles.streetInput}
/>
{/* <Button
title="clear"
onPress={clearSearchs}
style={styles.streetNumberInput}
// color="#aaa"
/> */}
</View>
{isSearching && <ActivityIndicator size="large" color="#1faadb" />}
<ScrollView>
{locationResults.map(el =>(
<LocationResultItem
{...el}
key={el.id.toString()}
fetchDetails={fetchDetails}
{...{clearSearchs}}
// query={{
// location: '45.526298, 4.873333',
// radius: '15000', //15 km
// strictbounds: true,
// }}
/>
))}
</ScrollView>
{/* <Text></Text> details a importer 2 way binding*/}
</React.Fragment>
)}
</GoogleAutoComplete>
Hi @EspacesTempsStudio, Could you implement the radius and location?
Is Nearby Search available? https://developers.google.com/places/web-service/search#PlaceSearchRequests
@dancomanlive I will add this to the features for v1, didn't even know that exist
Thank you :)
For a location you can example use the restrict by country here https://github.com/EQuimper/react-native-google-autocomplete#restrict-by-country
@EQuimper Is there any way to restrict by city or province as well? Thanks for the great api!
@victor-z-xiong didn't check google yet but if the api can I will make the change so this will be available.