A
A
Aidar2019-05-21 16:05:25
JavaScript
Aidar, 2019-05-21 16:05:25

How to pull up the contents of the label on the yandex map?

There is a map with labels. I need that when I click on the label, the alert displays the text of the label, which is specified in the array myCoords in the value text . Now here's what I have https://jsfiddle.net/w2vtmcz1/

Now the coordinates are displayed there, but I need text. I went through the documentation, honestly, but I don’t understand what method is needed to display the text. For coordinates, geometry.getCoordinates() is executed there

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-05-21
@Aderus

Your labels have no content, nothing to pull up.
You can get the desired text from the array by the label index:

const index = myCollection.indexOf(e.get('target'));
alert(myCoords[index].text);

UPD. It is not very clear why alert is needed here at all. Set the labels to balloonContent - the desired text will be displayed via pop-up windows.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question