X
X
xonar2020-02-10 16:56:55
JavaScript
xonar, 2020-02-10 16:56:55

How, when clicking on an element, move to the desired mark on the Yandex map?

Made a page where there is a map with several labels on it. And under the map there are blocks with information on each label. How to make it so that when you click on a certain block on the map, the focus moves to this mark and the scale of this mark increases?

Link

Something like an anchor.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
granty, 2020-02-11
@xonar

When you click on the balloon (label), this is easy to do. Go to this demo from Yandex or this demo , correct the javascript code right there and click the "Update" button. And see how it works and debug the code right there.
How to center / scale the map by clicking on the balloon - there is a code example on the Yandex blog.
If you need to intercept clicks specifically on the map, hang up a listener for the click on the map event:

myMap.geoObjects.events.add('click', function (e) {
  var targetObject = e.get('target');
  // . . .
  }
, determine the click coordinates and the closest balloon to them. Center and scale the map as needed. There are plenty of examples on Yandex itself (from the developers of I-maps themselves), you can collect what you need without even understanding the topic deeply.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question