Having some trouble extracting information from the Google Maps API into my application using JavaScript. I'm struggling to figure out how to access the data in the returned JSON object.
var site = "./maps/scripts/reverseGeocode/locale.php";
var params = "lat="+lat+"&"+"lng="+lng;
var object = system.functions().ajax(site, params);
var result = object.address_components[0];
alert(result);
The JSON object looks like this...
{
"results" : [
{
"address_components" : [
... (JSON object details omitted for brevity) ...
],
"formatted_address" : "24 Carabella St, Kirribilli NSW 2061, Australia",
"geometry" : {
... (JSON object details omitted for brevity) ...
},
"types" : [ "street_address" ]
},
{
... (Next JSON object details omitted for brevity) ...
}
],
"status" : "OK"
}
I'm trying to access the address component but I'm struggling to navigate the object correctly. Can anyone assist me?
"long_name" : "Kirribilli",
"short_name" : "Kirribilli",