I want to set different layers Visible True and False.
Currently I am use JavaScript for that like below:
function toggleLayer(layerId) {
debugger;
var layer = Map1.getLayer(layerId);
if (layer) {
if (layer.visibility) {
layer.visibility = false;
Map1.redrawLayer(layerId);
}
else {
layer.visibility = true;
Map1.redrawLayer(layerId);
}
}
};
Now here problem is If layer was Visible false and when I check check box then its visible true and visible on map,
but when I uncheck any checkbox that time visible layer can not set false, so what is the problem??
Set Layer Visible True/False
Hi Vivek,
Please try this code as below:
function toggleLayer(layerId) {
var layer = Map1.getLayer(layerId);
if (layer) {
if (layer.visibility) {
layer.setVisibility(false);
Map1.redrawLayer(layerId);
}
else {
layer.visibility = true;
Map1.redrawLayer(layerId);
}
}
};
Regards,
Don
Thanks Don,
It’s Works…
Hi Vivek,
I am glad to hear that works for you.
Regards,
Don