C
C
constlapkin2021-02-26 10:45:22
JavaScript
constlapkin, 2021-02-26 10:45:22

How to trigger a click event in Yandex Map API?

There is a map object (polygon): I have written a function that sets the data for the balloon and opens it when clicking on this region of the map: Sample cases that I want to achieve:
var region1 = new ymaps.GeoObject({ ... });
region1.events.add('click', function (e) { ... });

  • After searching for the desired address using ymaps.SuggestView(), call the click event on the found coordinates to work out the function (opening the balloon).
  • Separate buttons that change the information inside the balloon. (Here, the information is changed in the balloon using the internal logic of the flags, but for this you need to reopen the balloon). In this case, I see a solution to the problem like this:
    save the coordinates of the balloon -> close it -> trigger a click event at the same coordinates

How to trigger a click event passing map coordinates?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2021-02-26
@constlapkin

It is necessary not onClickto call, but to take the desired marker and call itopenBalloon

A
Anton Shamanov, 2021-02-26
@SilenceOfWinter

...add.call(this or whatever scope you need, coordinates). popular ide allow you to view the structure of objects in a convenient way. ymaps use the same js incl. it’s better to spend time not on learning managerial slang, but on js and api ymaps manual.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question