M
M
mills2018-12-20 09:25:33
JavaScript
mills, 2018-12-20 09:25:33

Yandex clustering, freezes when approaching and does not click on the cluster, what is the error?

Hello!
I don't understand clustering!
In the existing clustering code, I implemented the clustering Yandex sandbox code https://tech.yandex.ru/maps/jsbox/1/clusterer_create/
Everything seems to show for the given tasks, but here's a problem:

  1. When approaching, the map freezes tightly, it displays errors in the console, but I don’t understand the error
  2. Clusters that were clickable with a photo are not clickable!

Tell me, what's the problem? Map on Bitrix. Here is the map itself: univerokrug.hse.perm.ru/okrug/#map
Code. Yes, perhaps dirty, but for now I will only adapt the clustering to what was before me:
ymaps.ready(function () {
    var myMap = new ymaps.Map('map', {

<?php
if (isset($maxCOORD1) and (abs($maxCOORD1) != 0))  { ?>
            center: [<?= $maxCOORD1 + ($maxCOORD1 - $minCOORD1) / 2; ?>, <?=  $minCOORD2 + ($minCOORD2 - $minCOORD2) / 2; ?>],
            zoom: 12,
<?php } else { ?>
            center: [35, 25],
            zoom: 2,
<?php } ?>
      controls: ['zoomControl'],

        }),

        clusterer = new ymaps.Clusterer({
 
            preset: 'islands#invertedOrangeClusterIcons',
 
            groupByCoordinates: false,

            clusterHideIconOnBalloonOpen: false,
            geoObjectHideIconOnBalloonOpen: false
        }),

        getPointData = function (index) {
            return {
                balloonContentBody:item.content,
                clusterCaption: '<strong>' + item.hint + '</strong>'
            };
        },

        getPointOptions = function () {
            return {
                iconLayout: layout
            };
},


geoObjects = [];

var items = <?= json_encode($items); ?>;
      for (i in items) {
  var item = items[i];
  if (item.coord) {
      var layout = ymaps.templateLayoutFactory.createClass('<div class="placemark_layout_container"><div title="' + item.hint + '" class="circle_layout hint' + item.id + '"></div>');
      myPlacemark = new ymaps.Placemark(
    item.coord, {
        hintContent: item.hint, 
        balloonContent: item.content
    }, {
        iconLayout: layout,
        iconShape: {
      type: 'Circle',
      radius: 22
        }
    });

        geoObjects[i] = new ymaps.Placemark(item.coord, getPointData(i), getPointOptions());
  } 

 

    }

    clusterer.options.set({
        gridSize: 80,
        clusterDisableClickZoom: true
    });


    clusterer.add(geoObjects);
   	myMap.geoObjects.add(clusterer, myPlacemark);
    

    myMap.setBounds(clusterer.getBounds(), {
        checkZoomRange: true
    });
    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mills, 2018-12-20
@mills

I checked, the hang seems to be due to the fact that there are empty coordinates [""] in "item.coord" ....
Can anyone tell me how to skip empty coordinates?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question