Please see this: http://gisdev.clemson.edu/fireflies
Toward the top right are three checkboxes and I am trying to make them work like radio buttons. Part of the programming is working but here is something which is problematic:
Initially, the 'Counties' checkbox is checked. And if I were to click on the 'Hydric Soil Rating' checkbox and then click back on the Counties checkbox the Hydric checkbox still stays checked. The console doesn't output anything, meaning the value of checkboxes_controls
variable gets lost when the problem happens.
Here is relevant code:
var checkboxescontainer = document.querySelectorAll('.leaflet-control-layers-overlays');
var checkboxes_controls = checkboxescontainer[0].children;
$(checkboxes_controls).each(function()
{
console.log($.trim($(this).text()));
if (eventtype === 'add')
{
if (layername === $.trim($(this).text()))
{
// don't do anything but uncheck all others--making them work like radio buttons
}
else
{
$(this).find('input:checkbox').attr('checked', false);
}
}
});
Any idea?
Edit I see the problem: Clicking on the Counties layer the second time to select that doesn't even fire the layer 'Add' event because I am merely sending the layers back and front. Hmmmm.