Trying to get an array of view coordinates
[ [55.75, 37.50], [55.75, 37.71], [55.70, 37.70] ] Code
var coords = []; for ( var i = 0; i < addresses.length; i++ ) { ymaps.geocode(addresses[i], {results: 1 }).then(function (res) { console.log(res.geoObjects.get(0).geometry.getCoordinates()); // ok coords.push(res.geoObjects.get(0).geometry.getCoordinates()); }); } console.log(coords); // empty At the output, I get an empty array: (
console.log(coords);runs beforegeocodecalls complete. Read about asynchrony and promises - Alexey Ten