1

This JSfiddle example currently changes the visibility of a layer using two individual buttons.

However, i want to change this to just one check-box, the check-box in this case has been styled by Bootstrap Check-box.What would be the most simple method to bind the set.visibility command to this?

Edit: I have also tried to do this with a function toggleOSM()linked the onClick of the check-box as per this JSFiddle but it doesn't appear to work.

1

Use the onSwitchChange option of bootstrapSwitch:

$("[name='my-checkbox']").bootstrapSwitch({
    onSwitchChange: function (event, state) {
        rasterLayer.setVisible(state)
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.