Почему эта переменная не определена или не возвращена?

У меня есть следующий код:

/*
 * converts a string to geolocation and returns it
 */

function stringToLatLng(string){
    if(typeof string == "string"){
        geocoder = new google.maps.Geocoder();
        geocoder.geocode( { 'address': string}, function(results, status) {
           if (status == google.maps.GeocoderStatus.OK) {
              console.log("LatLng: "+results[0].geometry.location);
              return results[0].geometry.location;
           } else {
              console.log("Geocode was not successful for the following reason: " + status);
           }
        });
   }
}

LatLng выводит правильное местоположение на консоль, но когда я пишу это:

var pos = stringToLatLng('New York');
            console.log(pos);

я получилundefined назад. Это почему? Спасибо

Ответы на вопрос(2)

Ваш ответ на вопрос