jeudi 8 avril 2021

Keeping other sub check box on and the other off

I'd like to keep SAC layer turned off and the other two checkboxes on, but unchecking the SAC checkbox doesn't work. I am not sure how to turn of the SAC checkbox while the main checkbox (Biological) is still on

  $("#Biological").change(function(event) {
  event.preventDefault();
if ($(this).prop("checked")) {
  $("#SAC").prop('checked', true)
  $("#SSSI").prop('checked', true)
if ($("#SAC").prop("checked", true)) {
  
  map.addLayer(SAC);        
  biologicalLegend.addTo(map);
  
} 

if ($("#SSSI").prop("checked", true)) {
  map.addLayer(SSSI);        
  biologicalLegend.addTo(map);
  
} 

  } else {
    $("#SAC").prop('checked', false)
   $("#SSSI").prop('checked', false)
   if ($("#SAC").prop("checked", false)) {
  
  map.removeLayer(SAC);
  biologicalLegend.remove();
  
  }
if ($("#SSSI").prop("checked", false)) {
  
  map.removeLayer(SSSI);
  biologicalLegend.remove();
  
  }


  }
});

enter image description here




Aucun commentaire:

Enregistrer un commentaire