Hello:
I hope somebody can provide me some insight and help to resolve the issue I am having.
The issue is to change the layer opacity - I am using JS APIs 3.2
I have base layer and a dynamic layer mapservice which has 4 layers.
the code:
for (j = 0; j < self.map.layerIds.length; j += 1) {
currentLayer = self.map.getLayer(self.map.layerIds);
console.log("curentLayer:", currentLayer);
if (currentLayer.id !== "baseLayer") {
currentLayer.setOpacity(value);
currentLayer.refresh();
This does not refreshes the dynamic layer opacity, but later as the part of the workflow if I reloads the layers, it works!
And on looking is closely thru Chrome developer tools I found that map.getLayer method does not return the same layer object.
The layer object in both instace when it does not work and when it works is very similar except when it does not work, the layer object does not have OnOpacityChange method. Please see the attached images.
I am just very confused as why same method (map.getLayer) returns two different object and what I should do to fix it.
Any help and insight is greatly appreciated.