> 
> **Possible Duplicate:**  
> 
> [Undefined is not a function, Google Geolocation](https://stackoverflow.com/questions/11798431/undefined-is-not-a-function-google-geolocation) 
> 
> 
> 

I am trying to get google reverse geocoding of location, it returns me undefined but on console.log it shows address

this is the function to get the value

```
function getLatLng(latlng, callback) {
    var codedAddress;

    geocoder.geocode({'latLng': new google.maps.LatLng(40.730885,-73.997383)}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            codedAddress = results[1].formatted_address;
            console.log("codedAddress 1 = "+codedAddress);
        } else {
            alert("There was a problem with the map");
        }
        console.log("codedAddress 2 = "+codedAddress);
    });
    callback(codedAddress);
}

```

and this is my init code

```
function initialize() {
    var mapOptions = {
        zoom: 11,
        center: new google.maps.LatLng(5.386, 100.245),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);

    var location_coords = [
        <?php echo $output; ?>
    ];

    var location_status = [
        <?php echo $status; ?>
    ];

    var location_users = [
        <?php echo $users; ?>
    ];

    var location_date = [
        <?php echo $date; ?>
    ];

    for(i=0;i<location_coords.length;i++) {
      var traffic_options = {
        strokeColor: '#A52A2A',
        strokeOpacity: 0.8,
        strokeWeight: 1,
        fillColor: getColor(location_status[i]),
        fillOpacity: 0.5,
        map: map,
        center: location_coords[i],
        radius: 300
      };
      cityCircle = new google.maps.Circle(traffic_options);

    barr[i] = new Object;

    var marker = new google.maps.Marker({
        position: location_coords[i],
        map: map,
    });

    barr[i].marker = marker;
    barr[i].html = "<div><span style='font-size:9px'>Reported by " + location_users[i] + " on " + location_date[i] + "</span>" +
        "Traffic Location: " + getLatLng(location_coords[i], function(codedAddress) { return codedAddress; }) + 
        "<p>Traffic Condition: " + getCondition(location_status[i]) + "</p></div>";

    barr[i].infoWindow = new google.maps.InfoWindow({
        content: barr[i].html
    });

    barr[i].listener = makeClosure(i, barr[i].marker);
    }
}

```

The problem is within this statement

```
"Traffic Location: " + getLatLng(location_coords[i], function(codedAddress) { return codedAddress; })

```

How do i get the value over here instead of "undefined"

Thank you