Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict Autocomplete locationResults #17

Open
DanielMarcello opened this issue Dec 29, 2018 · 7 comments
Open

Restrict Autocomplete locationResults #17

DanielMarcello opened this issue Dec 29, 2018 · 7 comments

Comments

@DanielMarcello
Copy link

Thanks for this package is awesome.

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

@EQuimper
Copy link
Member

EQuimper commented Dec 29, 2018

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

@dancomanlive
Copy link

dancomanlive commented Jan 18, 2019

@EspacesTempsStudio
Copy link

Hi @EQuimper , can you explain how to use location and radius please?
i tried to add it in , and 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>

@georgeMorales
Copy link

georgeMorales commented Jul 3, 2019

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

@EQuimper
Copy link
Member

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

@victor-z-xiong
Copy link

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!

@EQuimper
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants