im trying to assign the value of my address to another variable but all i get is undefined or something like my url in the variable
here is my coding. i almost crack my head because of this.
function geoCoding(displayname, trackerModel, setupType, marker, index){
var setupMessageInfoWindow;
var geocoder = new google.maps.Geocoder();
    geocoder.geocode({'latLng': marker.getPosition()}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        if (results[1]) {
            var location = results[1].formatted_address;
        } else {
            alert('No results found at marker ' + marker.position);
        }
    } else {
        alert('Geocoder failed due to: ' + status);
    }
    });
    setupMessageInfoWindow = "<div height=\"300\" width=\"300\"><b>" + displayname + "</b>"
                        + " <br> Location : " + location
                        //+ " <br> Tracker id : " + userid
                        //+ " <br> imei : " + imei
                        + " <br> Tracker Type : " + trackerModel
                        //+ " <br> Mobile Number : " + 
                        //+ " <br> Location : " + location;
                        + " <br> " + setupType
                        + "</div>" ;
    return setupMessageInfoWindow;
}
 
    