Answer the question
In order to leave comments, you need to log in
How to change the position of existing markers on the Yandex map when hovering with the mouse?
There is a map on the site (drupal 7).
It is necessary to make it so that when you hover over the map marks with the mouse, they move slightly up (and then, accordingly, return back), i.e. Roughly speaking, handle the "hover" event.
Answer the question
In order to leave comments, you need to log in
Well, to put it bluntly
ymaps.ready(init);
function init() {
var myMap = new ymaps.Map('map', {
center: [55.755773, 37.617761],
zoom: 9
}),
myPlacemark = new ymaps.Placemark(myMap.getCenter());
myMap.geoObjects.add(myPlacemark);
myPlacemark.events
.add('mouseenter', function (e) {
// Ссылку на объект, вызвавший событие,
// можно получить из поля 'target'.
var coords = e.get('target').geometry.getCoordinates();
coords[0] += 0.001;
coords[1] += 0.001;
e.get('target').geometry.setCoordinates(coords);
})
.add('mouseleave', function (e) {
var coords = e.get('target').geometry.getCoordinates();
coords[0] -= 0.001;
coords[1] -= 0.001;
e.get('target').geometry.setCoordinates(coords);
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question