C
C
Captain Cocoa2019-05-14 18:18:12
JavaScript
Captain Cocoa, 2019-05-14 18:18:12

How to make a label on Yandex.Map an anchor link to the block behind the map?

Can a marker on Yandex.Maps be made an anchor link?
That is, by clicking on a marker on the map, the site scrolls to the required block.
I sketched an example, you need to scroll to the #pin1 block by clicking on the first label, and to the #pin2 block by clicking on the second label.
DEMO: https://jsfiddle.net/dn2aovts/1/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-05-14
@RadCor

Just add a click handler to the label:

placemark.events.add('click', () => {
  // здесь дёргаете scrollTo или scrollIntoView
});

https://jsfiddle.net/9xskoczg/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question