L
L
Lero622021-10-19 08:32:34
JavaScript
Lero62, 2021-10-19 08:32:34

How to show a block in Yandex maps when hovering over a marker inside a cluster?

How to show a block independent of Yandex maps when hovering over a label, but not on a cluster?

Here is my mock

ymaps.ready(init); 
      var addMap;
      function init () {
        var coords = [
          [56.023, 36.988],
          [56.025, 36.981],
          [56.020, 36.981],
          [56.021, 36.983],
          [56.027, 36.987]
        ];

        var myClusterer = new ymaps.Clusterer();
        var myGeoObjects = [];

        var addMap = new ymaps.Map("content-map", {
          center: [55.755811, 37.617617], 
          zoom: 10,
          controls: []
        }, {
          autoFitToViewport: 'always',
          searchControlProvider: 'yandex#search'
        });

        var myCollection = new ymaps.GeoObjectCollection();

        for (var i = 0; i<coords.length; i++) {
          myGeoObjects[i] = new ymaps.GeoObject({
            geometry: {
              type: "Point",
              coordinates: coords[i]
            }
          });
        }
        addMap.geoObjects.add(myCollection);



        myClusterer.add(myGeoObjects);
        addMap.geoObjects.add(myClusterer);
          
        myClusterer.events.add('mouseenter', function (e) {
          $('.div').show()
        })

        myClusterer.events.add('mouseleave', function (e) {
          $('.div').hide()
        });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question