react-native-google-autocomplete icon indicating copy to clipboard operation
react-native-google-autocomplete copied to clipboard

Restrict Autocomplete locationResults

Open DanielMarcello opened this issue 6 years ago • 7 comments

Thanks for this package is awesome.

Is there any way to restrict the locationResults according to a specified location and using the radius prop?

DanielMarcello avatar Dec 29 '18 17:12 DanielMarcello

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 avatar Dec 29 '18 17:12 EQuimper

Is Nearby Search available? https://developers.google.com/places/web-service/search#PlaceSearchRequests

dancomanlive avatar Jan 18 '19 05:01 dancomanlive

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>

EspacesTempsStudio avatar Feb 11 '19 15:02 EspacesTempsStudio

Hi @EspacesTempsStudio, Could you implement the radius and location?

georgeMorales avatar Jul 03 '19 20:07 georgeMorales

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

EQuimper avatar Aug 30 '19 11:08 EQuimper

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 avatar Oct 25 '19 18:10 victor-z-xiong

@victor-z-xiong didn't check google yet but if the api can I will make the change so this will be available.

EQuimper avatar Oct 26 '19 12:10 EQuimper