Google Reverse Geocode results
I am attempting to read data from a google reverse geocode. Using the Google API, I am getting back a json response that looks something like this:
{
"results": [
{
"formatted_address": "23550 26 Mile Rd, Macomb, MI 48042, USA",
"types": [
"street_address"
],
"address_components": [
{
"types": [
"street_number"
],
"long_name": "23550",
"short_name": "23550"
},
{
"types": ["route"],
"long_name": "26 Mile Rd",
"short_name": "26 Mile Rd"
},
{
"types": [
"administrative_area_level_3",
"political"
],
"long_name": "Macomb",
"short_name": "Macomb"
},
{
"types": [
"administrative_area_level_2",
"political"
],
"long_name": "Macomb",
"short_name": "Macomb"
},
{
"types": [
"administrative_area_level_1",
"political"
],
"long_name": "Michigan",
"short_name": "MI"
},
{
"types": [
"country",
"political"
],
"long_name": "United States",
"short_name": "US"
},
{
"types": [
"postal_code"
],
"long_name": "48042",
"short_name": "48042"
}
],
"geometry": {
"location_type": "ROOFTOP",
"viewport": {
"northeast": {
"lat": 42.71895798029149,
"lng": -82.8724090197085
},
"southwest": {
"lat": 42.71626001970849,
"lng": -82.8751069802915
}
},
"location": {
"lat": 42.717609,
"lng": -82.873758
}
}
},
{
"formatted_address": "Macomb, MI 48042, USA",
"types": [
"postal_code"
],
"address_components": [
{
"types": [
"postal_code"
],
"long_name": "48042",
"short_name": "48042"
},
{
"types": [
"administrative_area_level_3",
"political"
],
"long_name": "Macomb",
"short_name": "Macomb"
},
{
"types": [
"administrative_area_level_2",
"political"
],
"long_name": "Macomb",
"short_name": "Macomb"
},
{
"types": [
"administrative_area_level_1",
"political"
],
"long_name": "Michigan",
"short_name": "MI"
},
{
"types": [
"country",
"political"
],
"long_name": "United States",
"short_name": "US"
}
],
"geometry": {
"bounds": {
"northeast": {
"lat": 42.7181329,
"lng": -82.8560809
},
"southwest": {
"lat": 42.62835,
"lng": -82.9769081
}
},
"location_type": "APPROXIMATE",
"location": {
"lat": 42.6937328,
"lng": -82.9178838
},
"viewport": {
"northeast": {
"lat": 42.7181329,
"lng": -82.8560809
},
"southwest": {
"lat": 42.62835,
"lng": -82.9769081
}
}
}
},
{
"formatted_address": "Macomb, MI, USA",
"types": [
"administrative_area_level_3",
"political"
],
"address_components": [
{
"types": [
"administrative_area_level_3",
"political"
],
"long_name": "Macomb",
"short_name": "Macomb"
},
{
"types": [
"administrative_area_level_2",
"political"
],
"long_name": "Macomb",
"short_name": "Macomb"
},
{
"types": [
"administrative_area_level_1",
"political"
],
"long_name": "Michigan",
"short_name": "MI"
},
{
"types": [
"country",
"political"
],
"long_name": "United States",
"short_name": "US"
}
],
"geometry": {
"bounds": {
"northeast": {
"lat": 42.7181329,
"lng": -82.8561299
},
"southwest": {
"lat": 42.627811,
"lng": -82.9769081
}
},
"location_type": "APPROXIMATE",
"location": {
"lat": 42.6651965,
"lng": -82.92864279999999
},
"viewport": {
"northeast": {
"lat": 42.7181329,
"lng": -82.8561299
},
"southwest": {
"lat": 42.627811,
"lng": -82.9769081
}
}
}
},
{
"formatted_address": "Macomb, MI, USA",
"types": [
"administrative_area_level_2",
"political"
],
"address_components": [
{
"types": [
"administrative_area_level_2",
"political"
],
"long_name": "Macomb",
"short_name": "Macomb"
},
{
"types": [
"administrative_area_level_1",
"political"
],
"long_name": "Michigan",
"short_name": "MI"
},
{
"types": [
"country",
"political"
],
"long_name": "United States",
"short_name": "US"
}
],
"geometry": {
"bounds": {
"northeast": {
"lat": 42.897541,
"lng": -82.7059762
},
"southwest": {
"lat": 42.447055,
"lng": -83.102891
}
},
"location_type": "APPROXIMATE",
"location": {
"lat": 42.7168759,
"lng": -82.82097399999999
},
"viewport": {
"northeast": {
"lat": 42.897541,
"lng": -82.7059762
},
"southwest": {
"lat": 42.447055,
"lng": -83.102891
}
}
}
},
{
"formatted_address": "Michigan, USA",
"types": [
"administrative_area_level_1",
"political"
],
"address_components": [
{
"types": [
"administrative_area_level_1",
"political"
],
"long_name": "Michigan",
"short_name": "MI"
},
{
"types": [
"country",
"political"
],
"long_name": "United States",
"short_name": "US"
}
],
"geometry": {
"bounds": {
"northeast": {
"lat": 48.28764289999999,
"lng": -82.413474
},
"southwest": {
"lat": 41.696118,
"lng": -90.4181358
}
},
"location_type": "APPROXIMATE",
"location": {
"lat": 44.3148443,
"lng": -85.60236429999999
},
"viewport": {
"northeast": {
"lat": 48.2627089,
"lng": -82.413474
},
"southwest": {
"lat": 41.696118,
"lng": -90.4181358
}
}
}
},
{
"formatted_address": "United States",
"types": [
"country",
"political"
],
"address_components": [
{
"types": [
"country",
"political"
],
"long_name": "United States",
"short_name": "US"
}
],
"geometry": {
"bounds": {
"northeast": {
"lat": 71.389888,
"lng": -66.94976079999999
},
"southwest": {
"lat": 18.9110642,
"lng": 172.4546966
}
},
"location_type": "APPROXIMATE",
"location": {
"lat": 37.09024,
"lng": -95.712891
},
"viewport": {
"northeast": {
"lat": 49.38,
"lng": -66.94
},
"southwest": {
"lat": 25.82,
"lng": -124.39
}
}
}
}
],
"status": "OK"
}
The question is, when mapping the response, how can i specify the different types. For instance, I want to get out the type of "street_number" or "postal_code" from "address_components".
Also, if there is another route to reverse geocode an address from Tiggzi, I would be willing to explore that as an option.
Thank you!
Matt