react-google-autocomplete
react-google-autocomplete copied to clipboard
Want to get auto Complete when I switch countries
Thanks a lot, great project
<Autocomplete
apiKey={YOUR_GOOGLE_MAPS_API_KEY}
style={{ width: "90%" }}
onPlaceSelected={(place) => {
console.log(place);
}}
options={{
types: ["(regions)"],
componentRestrictions: { country: "us" },
}}
defaultValue="Amsterdam"
/>;
Modified country parameters
<Autocomplete
apiKey={YOUR_GOOGLE_MAPS_API_KEY}
style={{ width: "90%" }}
onPlaceSelected={(place) => {
console.log(place);
}}
options={{
types: ["(regions)"],
componentRestrictions: { country: "gb" },
}}
defaultValue="Amsterdam"
/>;
Switch from us to gb, but the data obtained is still us
Hey
I'm also updating the options prop and the autocomplete is not responding to that. I believe there is a need to recreate the component registration to google but I'm not sure how.
Please advise
Thanks
Everything works, check if you accidentally use google api key with already set region in html.
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" async defer></script>
