The recently released Google maps API v3 returns geocoding info in json
format as shown below. I am sure there is an elegant way to extract the
lat/lng but I have failed to find it after many attempts - can anyone
help? Thanks in advance.
{
“status”: “OK”,
“results”: [ {
“types”: [ “point_of_interest”, “establishment” ],
“formatted_address”: “Buckingham Palace, Westminster, London, UK”,
“address_components”: [ {
“long_name”: “Buckingham Palace”,
“short_name”: “Buckingham Palace”,
“types”: [ “point_of_interest”, “establishment” ]
}, {
“long_name”: “London”,
“short_name”: “London”,
“types”: [ “locality”, “political” ]
}, {
“long_name”: “Westminster”,
“short_name”: “Westminster”,
“types”: [ “administrative_area_level_3”, “political” ]
}, {
“long_name”: “Greater London”,
“short_name”: “Gt Lon”,
“types”: [ “administrative_area_level_2”, “political” ]
}, {
“long_name”: “England”,
“short_name”: “England”,
“types”: [ “administrative_area_level_1”, “political” ]
}, {
“long_name”: “United Kingdom”,
“short_name”: “GB”,
“types”: [ “country”, “political” ]
} ],
“geometry”: {
“location”: {
“lat”: 51.5007890,
“lng”: -0.1422640
},
“location_type”: “APPROXIMATE”,
“viewport”: {
“southwest”: {
“lat”: 51.4938426,
“lng”: -0.1582714
},
“northeast”: {
“lat”: 51.5077344,
“lng”: -0.1262566
}
}
}
} ]
}