A
A
adun32018-07-05 15:49:44
Yandex maps
adun3, 2018-07-05 15:49:44

How to display labels on Yandex maps on click?

Coordinates come to the template, X and Y.
I put labels in the cycle:

var myGeoObjects = [];
                                                            myGeoObjects = new ymaps.Placemark([x,y],{
                            balloonContentBody: "текст1",
                            });
                        var clusterer = new ymaps.Clusterer({
                            clusterDisableClickZoom: false,
                            clusterOpenBalloonOnClick: false,
                            });
                        clusterer.add(myGeoObjects);
                        myMap.geoObjects.add(clusterer);
                        myMap.behaviors.disable('scrollZoom');

As a result, I have a map with labels.
How can I make it so that when I poke some div with an address not in the map, I will see the label text I need (balloonContentBody) on the map?
well, i.e. what should be inside:
$('.address').click(function() {
                    }
                );

I just do not understand how best to make control over labels.
I tried it in a terrible way, like this:
myMap.hint.open([$(this).attr("coordx"), $(this).attr("coordy")]);

But this is not at all correct (in the diva to make coordinate attributes) and it does not work.
Please tell me the best way to do this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2018-07-06
@adun3

Iterate through all the tags and find with the desired id. Or have a ready dictionary id=>marker.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question