E
E
Evgeny Pitaev2014-06-04 10:04:31
Yandex maps
Evgeny Pitaev, 2014-06-04 10:04:31

Events on Yandex.Maps

If there is one myPlacemark balloon on the page, then you can simply substitute its coordinates and, when clicked, enlarge the map with these coordinates, but I have more than one element on the map, which raises the question of how to get the coordinates of the balloon when clicking on it and substitute them here myMap.setCenter([55.790139, 37.814052],15);
Example for one balloon

var myPlacemark = new ymaps.Placemark([55.790139, 37.814052], {
            balloonContent: ''
        }, {
            preset: 'islands#circleDotIcon',
            iconColor: '#1faee9'
        });
    
    myMap.geoObjects
        .add(myGeoObject)
        .add(myPlacemark);
    myPlacemark.events.add('click', function (e) {
        myMap.setCenter([55.790139, 37.814052], 15);
    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Pitaev, 2014-06-04
@jDeuterium

this issue was resolved

myPlacemark.events.add('click', function (e) {
        var coords = e.get('coords');
        myMap.setCenter(coords, 15);
});

But now how to make this code work when you click on any balloon?
those. now only works for myPlacemark, but not for myPlacemark2, myPlacemark3, ...,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question