I have a simular problem.
I use the slider control on my overlay maps and changed the select buttons into radio buttons.
Then I used the 'opacitySlider.setOpacityLayer()' in an 'if else if'clause and although the 'else if'block is executed only the first overlay's opacity is controlled (in the 'if' code block).
The alert statement is returning the right overlay name
This control works outside an 'if else if' clause.
What would you suggest?
'loon' and 'nautz' are tiled overlays
Here is the code:
var opacitySlider = new L.Control.opacitySlider();
m.addControl(opacitySlider);
$(document).ready(function () {
$('input[name="leaflet-control-layers-selector"]').on('change', function() {
var sjabloonName = $('input[name="leaflet-control-layers-selector"]:checked+span').text();
var overlayName = jQuery.makeArray( sjabloonName );
if ($.inArray("Van Loon 1646",overlayName)){
alert(overlayName); //returns "Van Loon 1646"
opacitySlider.setOpacityLayer(loon);
loon.setOpacity(0.5);
}
else if ($.inArray("Nautz 1822",overlayName)){
alert(overlayName); //returns "Nautz 1822"
opacitySlider.setOpacityLayer(nautz);
nautz.setOpacity(0.5);
}
});
});
I have a simular problem. I use the slider control on my overlay maps and changed the select buttons into radio buttons. Then I used the 'opacitySlider.setOpacityLayer()' in an 'if else if'clause and although the 'else if'block is executed only the first overlay's opacity is controlled (in the 'if' code block). The alert statement is returning the right overlay name This control works outside an 'if else if' clause. What would you suggest? 'loon' and 'nautz' are tiled overlays Here is the code: