Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
leaflet show or hide layers wfs cql_filter

i use the library Leaflet-WFST. So I have both wms and wfs layers. With wms, everything is simple there is cql_filter. I am writing a code where cql_filter is applied when clicking on the checkbox, here is the code:

$('#s23').click(function(){
if($("#s23").is(":checked")){
    if(layer.wmsParams.cql_filter != '' && layer.wmsParams.cql_filter.includes('layer_id=23') == false){
     layer.setParams({ cql_filter: layer.wmsParams.cql_filter + ' OR layer_id=23' });
     }else
     layer.setParams({ cql_filter: 'layer_id=23' });
     layer.setOpacity(1);
}else if(layer.wmsParams.cql_filter.includes(' OR layer_id=23') == true){ l_edit = layer.wmsParams.cql_filter.replace(" OR layer_id=23", "");
layer.setParams({ cql_filter: l_edit });
}else if(layer.wmsParams.cql_filter.includes('layer_id=23 OR ') == true){ l_edit = layer.wmsParams.cql_filter.replace("layer_id=23 OR ", "");
layer.setParams({ cql_filter: l_edit });
}else  layer.setParams({ cql_filter: '' });
     console.log(layer.wmsParams.cql_filter);
});
$('#s29').click(function(){
if($("#s29").is(":checked")){
   console.log(layer);
    if(layer.wmsParams.cql_filter != '' && layer.wmsParams.cql_filter.includes('layer_id=29') == false)
     layer.setParams({ cql_filter: layer.wmsParams.cql_filter + ' OR layer_id=29' });
     else
     layer.setParams({ cql_filter: 'layer_id=29' });
     layer.setOpacity(1);
     console.log(layer.wmsParams.cql_filter);
}else if(layer.wmsParams.cql_filter.includes(' OR layer_id=29') == true){ l_edit = layer.wmsParams.cql_filter.replace(" OR layer_id=29", "");
layer.setParams({ cql_filter: l_edit });
}else if(layer.wmsParams.cql_filter.includes('layer_id=29 OR ') == true){ l_edit = layer.wmsParams.cql_filter.replace("layer_id=29 OR ", "");
layer.setParams({ cql_filter: l_edit });
}else  layer.setParams({ cql_filter: '' });
     console.log(layer.wmsParams.cql_filter);
});

Here, if cql_filter is added when the checkbox is clicked, if it is empty, then cql_filter: 'layer_id=23' is triggered, and if there is something in cql_filter, then cql_filter: layer.wmsParams.cql_filter + ' OR layer_id=23' also if the checkbox was cleared, then this layer_id is removed from cql_filter.

I can use this code:

var layer_23 = new L.Filter.EQ('layer_id', 23);
 //var OR = new L.Filter.Or(layer.options.filter, layer_23);
 layer.options.filter = layer_23;
layer.loadFeatures(layer_23);

To add a new filter, but I don't know how I can remove or edit it.

The question is, how can the same thing be done?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!