I have this json. I am using Reverse Geocoding API from Google. I hit the get request in given url and this is the Response I am getting.
{
"results": [
{
"address_components": [
{
"long_name": "Goth Haji Umed Ali Gabole-Konker Road",
"short_name": "Goth Haji Umed Ali Gabole-Konker Rd",
"types": [
"route"
]
},
{
"long_name": "Haji Umaid Ali Goth",
"short_name": "Haji Umaid Ali Goth",
"types": [
"political",
"sublocality",
"sublocality_level_2"
]
},
{
"long_name": "Gadap",
"short_name": "Gadap",
"types": [
"political",
"sublocality",
"sublocality_level_1"
]
},
{
"long_name": "Karachi",
"short_name": "Karachi",
"types": [
"locality",
"political"
]
},
], "status": "OK"}
And this is my code
function successFunction(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
var url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + lng + "&key=AIzaSyBcV_CkYu5VvJb1ZZF8GWCAmyzhedGpYzk";
jQuery.get(url, function (result)
{
console.log(result);
}
);
}
JSON is in my console . I want to alert city name "Karachi". How can I get this?