Using Google Maps: a custom javascript function returning undefined
<p>I'm trying to return the variable <code>coord</code> from GetLocation, but it only returns undefined.
Any help appreciated!</p>

<pre><code>var coord = "";
function GetLocation(address) {

    var geocoder = new google.maps.Geocoder();

    geocoder.geocode( { "address": address }, function (results, status) {

        if (status == google.maps.GeocoderStatus.OK) {
            coord = ParseLocation(results[0].geometry.location);

            // This alert shows the proper coordinates 
            alert(coord);
        }
        else{ }

    });

    // this alert is undefined
    alert(coord);
    return coord;
}

function ParseLocation(location) {

    var lat = location.lat().toString().substr(0, 12);
    var lng = location.lng().toString().substr(0, 12);

    return lat+","+lng;
}
</code></pre>
