[GIS] Disable Leaflet layer check box in a layer control w/ zoom

leaflet

I would like to have layers listed in my layer control, but have their check boxes disabled when zoomed out beyond a certain level.

I am asking the same question that is found here, but with Leaflet instead of OpenLayers.

This is admittedly a "has this already been done" question. I could try to figure out if it can be translated easily from the OpenLayers example above, but maybe someone has accomplished this already?

Best Answer

This ended up being a little easier than I expected by using document.querySelectorAll to select checkboxes, and setting them to disabled=true.

Ended up finding help combining this answer from Stack Overflow with this about iterating over querySelectorAll (simple for loop).

Ended up with this:

var checks = document.querySelectorAll('[type = "checkbox"]'), i;
function disCheck() {
    for (i = 0; i < checks.length; ++i) {
        checks[i].disabled = true;

... with some more stuff following it, and calling it in my function that controls zoom stuff.