Answer the question
In order to leave comments, you need to log in
How to link the menu and labels on the map?
Hello, there is a list of objects in the sidebar and a map with labels,
myMap.geoObjects
.add(new ymaps.Placemark([51.707730, 94.420949], {
balloonContent: '«Объект 1»'
}, {
preset: 'islands#icon',
iconColor: '#0095b6'
}))
.add(new ymaps.Placemark([51.716023, 94.430310], {
balloonContent: 'Объект2'
}, {
preset: 'islands#icon',
iconColor: '#0095b6'
}))
Answer the question
In order to leave comments, you need to log in
Move to the label and open the balloon like this:
//click opens the balloon and moves the map, the center coordinate of the label
$(document).on('click','.oneLevelSpan',function(){
var id = $(this).data ("id");
var coords = myPointGeoObject[id].geometry.getCoordinates();
myPointGeoObject[id].balloon.open();
myMap.setZoom(14).panTo(coords,{
flying: 1
});
} );
But if you want to change the style of the balloon... then probably remove the marker from the collection and create a new one with different properties.
Accordingly, you get two onClics - on the menu item and on the marker.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question