In this code:
$(document).ready(function() {
var lat = 0;
var lng = 0;
function getLatLng(address) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
lat = results[0].geometry.location.lat(); //how do I access lat
lng = results[0].geometry.location.lng() //and lng outside function ormake it global
}
});
alert(lat); // does not display only show's the 0
}
getLatLng();
});
I want the alert(lat)
to show the lat not zero.
how can I access this?
thanks in advance!