I am using google Geocoding API to store the cities in the DB on demand.I provided an input field for the user to enter their city.I used googles places autocomplete for that.
I would like to store the city and its country what ever enter ed in the input field. Calling google geocoding API with the with data from input field, returned data in JSON.
I looked into address_components
got country in it. Then I took object in address_components
where types = locality
. The problem is,For some locations typed in the input field, The JSON from google geocoding API doesn't have types = locality
. So in these cases, which one among the objects in address_components
should I store as city in my DB.
this website is exampale of google geocoding api https://findcity.in/
Need suggestions. The question may not be clear earlier. So I edited it. Thanks