function asyncGeocode(params) {
return new Promise((resolve, reject) => geocoder.geocode(
params,
(results, status) => status === 'OK' ? resolve(results) : reject(status)
));
}
async function addressToCoords(local) {
var address = local;
var result = await asyncGeocode({address}).catch(status => {
console.log('Error: ' + status);
return '';
});
alert('Result is ' + result);
return result;
}
Подробнее...