console.log((initService('Moscow'))); // возвращает undefined
function initService(vall) {
var displaySuggestions = function (predictions, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
alert(status);
return;
}
console.log(predictions); // возвращает несколько объектов
return predictions;
};
var service = new google.maps.places.AutocompleteService();
return service.getQueryPredictions({ input: vall }, displaySuggestions);
}
Что я делаю не так?