I want only city name without country using google
place API
For that I used react-places-autocomplete
I tried
types: ['(cities)']
But it returns "Newyork, NY, USA" instead of "Newyork, NY"
I just want "Newyork, NY".
It's not possible to remove country name from Place Autocomplete suggestions at this time.
However, there is an open feature request in Google's Issue Tracker which I suggest starring to increase visibility and subscribe to future updates: https://issuetracker.google.com/issues/35822039
Also check out this related thread for potential workarounds:
Google Places Autocomplete Remove State and Country from Result
Hope this helps!
For anyone looking to find a solution for like me, I found out that this feature has been added into the API as mentioned here
Good news! This feature is now available in the weekly channel.
To try this out, modify https://jsbin.com/qoxiwawuno/edit?html,js,output to set
region=us
(and add your API), then for instance typing "paris" will show
- Paris, France
- Paris, TX (no country name)
You can do so like this:
<script src="https://maps.googleapis.com/maps/api/jskey=API_KEY&callback=loadAutocomlete&libraries=places®ion=fr&v=weekly" async ></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With