i have this code to detect change on my checkbox.
if is true turn on layer if is not true turn off layer
in my map service the layer have id 14
Layers.findSublayerById(14).labelsVisible = true;
in console mark this
Solved! Go to Solution.
Hmm, I tested this functionality as a sanity check, and it is possible to do.
Test app (toggle state labels on and off with the button at the bottom)
Perhaps the MapServer you're using doesn't support dynamic layers? You need it to in order to make changes dynamically.
When you inspect the MapServer from REST, do you see:
Supports Dynamic Layers: true
Thank you for answering if it supports Dynamic Layers, my quick stop solution that works for me is to load the map again, for now I will stay with this solution later I will see the performance.
I have the solution i only need findSublayerById function .
var idcheck = event.target.getAttribute("data-id");
var sublayer = Layers.findSublayerById(parseInt(idcheck));
sublayer.visible = !sublayer.visible;