I’m trying out google maps and geocoding apis, and they’re so fast, love that. However, it returns data in odd ways. How can I determine what’s the country, state and city separately, to store them individually in my DB?
Just extract them from the geographic address.
Just figured it out. Filtering Address Components does the trick, usually:
"address_components" : [
{
"long_name" : "Paris",
"short_name" : "Paris",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Comté de Lamar",
"short_name" : "Comté de Lamar",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Texas",
"short_name" : "TX",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
}
]
Just filter the response by
administrative_area_level_1 & 2, locality, country