A
A
Alexander Andreev2019-02-18 14:23:34
Yandex maps
Alexander Andreev, 2019-02-18 14:23:34

How to open cluster balloon on hover?

There is a map with a list of partners of the company:

window.PartnersListMap.prototype = {
        init: function() {
            var self = this;

            self.createMap();
        },

        ...всякие прочие методы PartnersListMap...

Partners have a different type (shop, service partner A, service partner B, etc.), each type of partner is displayed with its own icon.
The cluster of partners looks like a pie chart, something like this is an example of a map .
I want to add a legend when hovering the mouse over a cluster. The legend will contain icons of types of partners, the name of the types and their number in the current cluster (on which the mouse is hovered).
I got the information for drawing the legend like this:
self.clusterer.events
  .add('mouseenter', function (e) {
      var target = e.get('target'),
      clusterPlacemark = e.get('cluster'),
      legend = {}; //Данные для легенды

      console.log('cluster mouseenter ');
                    
      target.properties._data.geoObjects.forEach(function(partner){
           if(!legend[partner.options._options.partnerType]){
           legend[partner.options._options.partnerType] = [];
      }
                        
     legend[partner.options._options.partnerType].push(partner.options._options.partnerId);

       });
      console.log(legend);  
});

The code is still raw, but in the legend variable, ultimately, there is something like an array
5c6a95ed858d3433882240.jpeg
where the key is the id of the partner type, for example 73 and the value is an array of partner identifiers, as a result there will be just a number (how many partners of type 73 are in the current cluster).
So, I can’t start the opening of the balloon from here (in the mouseenter event) (well, close it on the mouseleave). Tried through self.clusterer.balloon.open(), tried to find a method in target - nothing.

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