React-native-google-places-autocomplete: Restriction to particular area/city

Created on 4 Mar 2018  路  3Comments  路  Source: FaridSafi/react-native-google-places-autocomplete

Is there any customisation available to restrict my search to a particular area or region,
I've tried using the following but had no luck:
query={{
key: 'AIz***,
language: 'en', // language of the results
radius:2,
latitude: 24.946218,
longitude:67.005615
}}

I want to restrict my search only for the places within my city, any help would be highly appreciated

Thanks

Most helpful comment

To me the next work:

 <GooglePlacesAutocomplete
                                placeholder='Escribe una direcci贸n o lugar'
                                minLength={2}
                                autoFocus={true}
                                returnKeyType={'default'}
                                fetchDetails={true}
                                query={{
                                    key: '***********8',
                                    language: 'es', // language of the results
                                    location: '20.8840744, -100.7607736',
                                    radius: '15000', //15 km
                                    components:'country:mx',
                                    strictbounds: true,
                                }}
/>

All 3 comments

You can restrict the search by country.
Follow the code below:

query={{
     // available options: https://developers.google.com/places/web-service/autocomplete 
     key: 'YOUR API KEY', 
     language: 'en', // language of the results 
     types: '(cities)' // default: 'geocode' 
     components: 'country:us'
}}

Support Link: https://developers.google.com/places/web-service/autocomplete

To me the next work:

 <GooglePlacesAutocomplete
                                placeholder='Escribe una direcci贸n o lugar'
                                minLength={2}
                                autoFocus={true}
                                returnKeyType={'default'}
                                fetchDetails={true}
                                query={{
                                    key: '***********8',
                                    language: 'es', // language of the results
                                    location: '20.8840744, -100.7607736',
                                    radius: '15000', //15 km
                                    components:'country:mx',
                                    strictbounds: true,
                                }}
/>

@juliofalbo oh man, thanks for the query example. I couldn't figure out how to limit the search within a country, the documentation speaks only of the parameter that you can provide in the api call url, not as a query part.
Thanks a lot, saved me a lot of head ache.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

biks152207 picture biks152207  路  4Comments

lukBakTsh picture lukBakTsh  路  3Comments

GervaisYO picture GervaisYO  路  4Comments

tezahzulueta picture tezahzulueta  路  3Comments

RajanPN picture RajanPN  路  3Comments