how to get the marker coordinates from geoObjectCollection Yandex.Map

1.5k Views Asked by At

There is a collection of objects displayed on the map. There is an event on the click of the label. How to determine the coordinates of the label that was clicked? .get('coords) will not work, you need to get exactly the coordinates prescribed in the collection, but how can I not understand, I tried .getCoordinates(), but I did not understand how to prescribe correctly, or do something else here...

var myGeoObject = new ymaps.GeoObjectCollection(
   {
    preset: 'islands#blueIcon'
});
for (var i = 0; i < coords.length; i++) {
    myGeoObject.add(new ymaps.Placemark(coords[i]));
}
myMap.geoObjects.add(myGeoObject);

myGeoObject.events.add('click', function (e) {
        
});
1

There are 1 best solutions below

1
Danii Akhiyan On BEST ANSWER
myGeoObject.events.add('click', function (e) {
        var click_coord = e.get('target').geometry.getCoordinates();
});