'); $.ajax({ url: "/occurrence/legend" + MAP_VAR.query + "&cm=" + colourByFacet + "&type=application/json", success: function(data) { $('.legendTable').html(''); $.each(data, function(index, legendDef){ var legItemName = legendDef.name ? legendDef.name : 'Not specified'; addLegendItem(legItemName, legendDef.red,legendDef.green,legendDef.blue, legendDef ); }); $('.layerFacet').click(function(e){ var controlIdx = 0; MAP_VAR.additionalFqs = ''; MAP_VAR.removeFqs = '' $('#colourByControl').find('.layerFacet').each(function(idx, layerInput){ var $input = $(layerInput), fq; var include = $input.is(':checked'); if(!include){ MAP_VAR.additionalFqs = MAP_VAR.additionalFqs + '&HQ=' + controlIdx; fq = $input.attr('fq'); // logic for facets with missing value is different from those with value if(fq && fq.startsWith('-')){ // to ignore unknown or missing values, minus sign must be removed fq = fq.replace('-',''); } else{ // for all other values minus sign has to be added fq = '-' + fq; } // add fq to ensure the query in sync with dots displayed on map MAP_VAR.removeFqs += '&fq=' + fq; } controlIdx = controlIdx + 1; addQueryLayer(false); }); }); } }); } } MAP_VAR.layerControl.addOverlay(layer, 'Occurrences'); MAP_VAR.map.addLayer(layer); MAP_VAR.currentLayers.push(layer); for (let key in MAP_VAR.overlays) { MAP_VAR.map.addLayer(MAP_VAR.overlays[key]); } return true; } function addDefaultLegendItem(pointColour){ $(".legendTable") .append($('