I have the following code to fetch lattitude and longitude for given address but the permission to google url is denied .
function getlatlng(address, callback) { var addressval = address; var address; var url; var googleUrl = "http://maps.google.com/maps/api/geocode/json?"; var sensor = "&sensor=false";
if (addressval != null && addressval != "" && addressval.length != 0) {
address = "address=" + encodeURIComponent(addressval);
$.ajax({
url: googleUrl + address + sensor,
type: "POST",
async: false,
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(longlatJson) {
var jsonObj = JSON.parse(JSON.stringify(longlatJson));
var lat = jsonObj.results[0].geometry.location.lat;
var lng = jsonObj.results[0].geometry.location.lng;
cb(lat, lng);
},
error: function() { alert("unable to conect to google server"); }
});
}
}
This will be my function call to getlatlng for the given address
getlatlng(address, function(lat, lng) { alert(lat); alert(lng); ............... ...............
});