ymaps.ready(function () {
var myMap = new ymaps.Map('map', {
center: [50,50],
zoom: 5,
type: 'yandex#map',
controls: ['zoomControl', 'typeSelector','routeEditor','fullscreenControl','rulerControl']
}, {
searchControlProvider: 'yandex#search'
}),
clusterer = new ymaps.Clusterer({
preset: 'islands#darkGreenCircleIcon',
gridSize: 80
}),
geoObjects = [];
for (var i = 0; i < groups[0].items.length; i++) {
geoObjects[i] = new ymaps.Placemark(groups[0].items[i].center, {
balloonContentHeader: groups[0].items[i].name,
balloonContentFooter: groups[0].items[i].content,
hintContent: groups[0].items[i].hint
}, {
iconLayout: groups[0].items[i].resetIcon,
iconImageHref: groups[0].items[i].myIcon,
iconImageSize: groups[0].items[i].iconSize,
preset: 'twirl#nightStretchyIcon'
});
}
clusterer.add(geoObjects);
myMap.geoObjects.add(clusterer);
function clear_all () {
clusterer.removeAll();
myMap.geoObjects.remove(clusterer);
};
function checkState () {
geoObjects = [];
clear_all();
if ($('#all_problem').prop('checked')) {
for (var i = 0; i < groups[0].items.length; i++) {
geoObjects[i] = new ymaps.Placemark(groups[0].items[i].center, {
balloonContentHeader: groups[0].items[i].name,
balloonContentFooter: groups[0].items[i].content,
hintContent: groups[0].items[i].hint
}, {
iconLayout: groups[0].items[i].resetIcon,
iconImageHref: groups[0].items[i].myIcon,
iconImageSize: groups[0].items[i].iconSize,
preset: 'twirl#nightStretchyIcon'
});
}
} else if ($('#active').prop('checked')) {
for (var i = 0; i < groups[0].items.length; i++) {
if (groups[0].items[i].problem_status == "В процессе решения") {
geoObjects[i] = new ymaps.Placemark(groups[0].items[i].center, {
balloonContentHeader: groups[0].items[i].name,
balloonContentFooter: groups[0].items[i].content,
hintContent: groups[0].items[i].hint
}, {
iconLayout: groups[0].items[i].resetIcon,
iconImageHref: groups[0].items[i].myIcon,
iconImageSize: groups[0].items[i].iconSize,
preset: 'twirl#nightStretchyIcon'
});
}
}
} else if ($('#compl').prop('checked')) {
for (var i = 0; i < groups[0].items.length; i++) {
if (groups[0].items[i].problem_status == "Проблема решена") {
console.log(groups[0].items[i].problem_status);
geoObjects[i] = new ymaps.Placemark(groups[0].items[i].center, {
balloonContentHeader: groups[0].items[i].name,
balloonContentFooter: groups[0].items[i].content,
hintContent: groups[0].items[i].hint
}, {
iconLayout: groups[0].items[i].resetIcon,
iconImageHref: groups[0].items[i].myIcon,
iconImageSize: groups[0].items[i].iconSize,
preset: 'twirl#nightStretchyIcon'
});
}
}
};
clusterer.add(geoObjects);
myMap.geoObjects.add(clusterer);
};
$('#all_problem').click(checkState);
$('#active').click(checkState);
$('#compl').click(checkState);
});