this is my code :
$( document ).ready(function() {
var geocoder = new google.maps.Geocoder();
var lat= true;
var lng = true;
function codeAddress(address) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == "ZERO_RESULTS"){
var lat = 0;
var lng = 0;
}else if (status == "OK"){
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
}
});
return lat + "+" + lng; /// here i want to return lat & lng
}
var nr = $("#get_array").text();
var my_array = $("#get_array").attr("class");
my_array = my_array.split("|");
var string = "";
for(var i = 0; i < nr; i++){
item = codeAddress(my_array[i]);
//string = string + item + "|";
}
});
where i wrote the comment , there I want to return the lat & lng value , but it is empty. why ??? how can i return the lat and lnb variables ? thx