I'm using Google Maps to return the location name and state of where the user's location is. This is the portion I'm interested in:
"address_components" : [
{
"long_name" : "Salem",
"short_name" : "Salem",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Rockingham",
"short_name" : "Rockingham",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "New Hampshire",
"short_name" : "NH",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
}
]
Is there a way to find which objects contain the "locality" and "administrative_area_level_1" value and return the "long_name" string of the appropriate object using JavaScript or jQuery? How would I go about doing so?