Answer the question
In order to leave comments, you need to log in
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:
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question