Партнёр сервиса — канал «Руда». Рассказываем о бизнесе и карьере в digital без занудства и цензуры Агентство городских новостей «Москва» - События на карте
Меню Поиск

Коронавирус Новости

var pieClusterLayout = ymaps.templateLayoutFactory.createClass( '', { build: function() { pieClusterLayout.superclass.build.call(this); var node = this.getParentElement(); this.drawPieChart(node, this.getData().properties.get('geoObjects')); }, drawPieChart: function(node, data) { var size = {width: $(node).width(), height: $(node).height()}; var $canvas = $('
'); var angle = 0, total = data.length, start = 0; $(node).html($canvas); var r = Raphael($canvas[0], size.width, size.height); //Draw footage for chart var fr = size.width / 2; r.circle(fr, fr, fr).attr({ fill: "#f3f3f3", "stroke-width": 0 }); var sectors = new Array(); var scnt = 0; for(var i in data) { var grp = data[i].properties.get('pinGroup').toString(); if(!(grp in sectors)) { sectors[grp] = { count: 1, color: (groupColors.hasOwnProperty(grp)) ? groupColors[grp] : groupColors.def }; scnt++; } else sectors[grp].count++; } var chart = r.set(); if(scnt == 1) { //У нас только один сектор //В целях повышения производительности заменим path на circle var color = ''; for(var i in sectors) color = sectors[i].color; chart.push( r.circle(fr, fr, fr).attr({"fill": color, "stroke-width": 0}) ); } else if(scnt > 1) { for(var i in sectors) { var value = sectors[i].count, angleplus = 360 * value / total, color = sectors[i].color, p = this.drawChartSector(r, fr, fr, fr, angle, angle + angleplus, {fill: color, "stroke-width": 0}); angle += angleplus; chart.push(p); start += .1; } } var badge_rad = fr / 1.5; //Добавим тень к значку var start_point = fr + badge_rad, s1_1_move = size.width - start_point; r.path(["M", start_point / 1.05, fr / 1.6, "L", start_point + s1_1_move, fr * 1.1, "A", fr, fr, -45, 0, 1, fr, size.height, "L", s1_1_move * 1.5, fr + s1_1_move * 1.46, "L", start_point, fr / 1.3, "Z"]) .attr({fill: "#000", "stroke-width": 0, "fill-opacity": 0.3}); var badge = r.circle(fr, fr, badge_rad).attr({fill: '#f5f5f4', "stroke-width": 0}); //И блик сверху r.path([ "m", fr, 0, "a", 1, 1, 0, 1, 0, 0, size.height, "a", 1, -1.15, 0, 1, 1, 0, -size.height, "z"]).attr({fill: '#f5f5f4', "stroke-width": 0, "fill-opacity": 0.5}).rotate(90, fr, fr); var xcord = (total >= 10) ? fr - 1 : fr; r.text(xcord, fr, total).attr('font-size', '17px'); }, drawChartSector: function(paper, cx, cy, r, startAngle, endAngle, params) { var x1 = cx + r * Math.cos(-startAngle * rad), x2 = cx + r * Math.cos(-endAngle * rad), y1 = cy + r * Math.sin(-startAngle * rad), y2 = cy + r * Math.sin(-endAngle * rad); return paper.path(["M", cx, cy, "L", x1, y1, "A", r, r, 0, +(endAngle - startAngle > 180), 0, x2, y2, "z"]).attr(params); } } ); clusterer = new ymaps.Clusterer({ //clusterIconContentLayout: pieClusterLayout }); myMap = new ymaps.Map ("map", { center: [55.76, 37.64], zoom: 11, // behaviors: ["scrollZoom","default"] }); // myMap.controls.add('mapTools'); // myMap.controls.add('zoomControl'); // myMap.controls.add('typeSelector'); // myMap.controls.add('searchControl'); myMap.geoObjects.add(clusterer); console.log (materials) buildMapWithData(materials, true); } function pushNewFilterControl(id, title, animated) { if($('.ChoosenRubrics a[data-filter="' + id + '"]').length > 0) return false; var $control = $('
  • ' + title + '
  • '); if(animated) { $control.css('display', 'none'); $('.ChoosenRubrics ul').append($control); $control.slideDown(); } else $('.ChoosenRubrics ul').append($control); return true; } function buildMapWithData(data, affectsChackboxes) { if(typeof(affectsChackboxes)==='undefined') affectsChackboxes = false; if(affectsChackboxes) { $('.Rubrics select option').attr('disabled', 'disabled'); $('.ChoosenRubrics ul li').remove(); } if(clusterer != null) clusterer.removeAll(); for(i in data) { console.log (data[i]) //if($('#ImportantMark').is(":checked") && data[i].important != 1) continue; placeMark = new ymaps.Placemark([data[i].lat, data[i].long], { // Чтобы балун и хинт открывались на метке, необходимо задать ей определенные свойства. balloonContentHeader: '' + data[i].date + '', balloonContentBody: '' + data[i].title + '', balloonContentFooter: 'подробнее..', hintContent: data[i].title/* clusterCaption: data[i].title, balloonContent: data[i].date + '
    ' + data[i].title + '', pinGroup: data[i].group_id*/ },{ iconLayout: 'default#image', iconImageHref: data[i].icon, iconImageSize: [31, 38], iconImageOffset: [-13, -39] }); clusterer.add(placeMark); if(affectsChackboxes) { var $itm = $('.Rubrics select option[value=' + data[i].point_type + ']'); //pushNewFilterControl($itm.val(), $itm.text(), false); $itm.removeAttr('disabled'); } } pointsOnMap = data; //console.log('input:checkbox:checked', $('#MapFilters input:checkbox:checked').length); if ($('#MapFilters input:checkbox:checked').length > 0 ) { $('#ClearSettings').addClass('Show') } else { $('#ClearSettings').removeClass('Show') } } function getMaterialsForRubrics(rubrics) { var result = []; var materialTypes = []; $('.MaterialTypes input:checkbox:checked').each(function(){ materialTypes.push( $(this).val() ); }); console.log('materialTypes', materialTypes); for(var i in materials) { if (rubrics.length > 0) { if(rubrics.indexOf(materials[i].point_type) != -1) { if(materialTypes.length > 0 && materialTypes.indexOf(materials[i].type) != -1 || materialTypes.length == 0) { result.push(materials[i]); } } } else { if(materialTypes.length > 0 && materialTypes.indexOf(materials[i].type) != -1 || materialTypes.length == 0) { result.push(materials[i]); } } //console.log('getMaterialsForRubrics', materials[i].point_type, result, rubrics.indexOf(materials[i].point_type)); } return result; } function getMaterialsForFilters() { var rubrics = []; $('.Rubrics input:checkbox:checked').each(function(){ rubrics.push( $(this).val() ); }); var materialTypes = []; $('.MaterialTypes input:checkbox:checked').each(function(){ materialTypes.push( $(this).val() ); }); // return (rubrics.length > 0) ? getMaterialsForRubrics(rubrics) : materials; return (rubrics.length > 0 || materialTypes.length > 0 /*|| $('#ImportantMark').is(":checked")*/) ? getMaterialsForRubrics(rubrics) : materials; } $(document).ready(function(){ //$('#leftblock').waypoint('sticky', {stuckClass: 'stuckFilters', offset: 35}); ymaps.ready(init); $('#NewsMenu a').click(function(){ $('#NewsMenu a').removeClass('Active'); $(this).addClass('Active'); //Filter items by type var type = $(this).attr('rel'); console.log(type); if(type === undefined) return buildMapWithData(materials, true); var result = []; for(var i in materials) { if(materials[i].type == type) result.push(materials[i]); } buildMapWithData(result, true); }); $('.Rubrics input:checkbox').change(function(){ if($(this).val() > 0) { var $opt = $(this).find(':checked'); buildMapWithData( getMaterialsForFilters() ); $(this).prop('selectedIndex', 0); } }); $('.MaterialTypes input:checkbox').change(function(){ console.log($(this).val()); if($(this).val() != '') { var $opt = $(this).find(':checked'); buildMapWithData( getMaterialsForFilters() ); $(this).prop('selectedIndex', 0); } }); // $('#ImportantMark').click(function(){ // //alert ('ImportantMark.click'); // buildMapWithData( getMaterialsForFilters() ); // }); });
    Фильтры Карты
    Пожалуйста, укажите название Вашего СМИ/организации.
    Или просто представьтесь, если Вы частное лицо:
    Ок