Layerlist not updating

700
5
01-29-2013 08:20 PM
ToddDavis1
New Contributor III
Hi,

I have an issue with a session restore widget. The widget is based on a post that Robert did quite a few versions ago. The widget is designed to restore the layers that users had on. At version 3 the widget isn't working; the correct layers are becoming visible on the map, however the layerlist is not updating the sublayer checkboxes for dynamic services. Can anyone give me an idea of how to make the widget update the layerlist checkboxes to reflect the layers on the map?

This is the restore portion of the dynamic services

if (layer is ArcGISDynamicMapServiceLayer) {
layer.visible = acVisLayers[cLayId].visible;
ArcGISDynamicMapServiceLayer(layer).visibleLayers = acVisLayers[cLayId].visarray;

Thanks,
Todd
Tags (2)
0 Kudos
5 Replies
DanJensen
Occasional Contributor
I would change the second line in the code to use AppEvent.  Below is an example.


var dynMS:ArcGISDynamicMapServiceLayer = layer as ArcGISDynamicMapServiceLayer;
var lyrObject:Object=newObject;
lyrObject.layer=dynMS;
lyrObject.visible=acVisLayers[cLayId].visible;
AppEvent.dispatch(AppEvent.MAP_LAYER_VISIBLE, lyrObject);


but I just noticed that the layer object has a refresh() method.  Maybe that would work.

-Dan
0 Kudos
ToddDavis1
New Contributor III
Hi Dan,

The code is achieving the same result. That is, the service itself is been made visible but the underlying sublayer checkboxes are not been altered.

Any more ideas would be appreciated.

Thanks,
Todd
0 Kudos
AnthonyGiles
Frequent Contributor II
Todd,

This has always been an issue with the toc component, it does not update to programmatic changes to a layers visibility. If you do Come up with a solution I will be interested in your implementation as I am yet to find a solution.

Regards

Anthony
0 Kudos
DanJensen
Occasional Contributor
This code works for me, but there is one difference.  Instead of setting the visibleLayers equal to something I am adding and removing layers from the existing list.  Try this.  remove all items in the existing list, then re-add each layer id from the visarray object.  Let us know if this makes a difference.

-Dan
0 Kudos
DanJensen
Occasional Contributor
A reason has come up for me to investigate this extensively.  The TOC appears to be written from the stand point of it is the only widget that turns layers on and off.  It also seems to be written to use default visibility.  What it needs is to listen for an event that we can fire when we change the visible layers in another widget.  It would be nice if it also would use current visiblity when visible layers is set for a layer.  Since this is Robert Scheitlin's creation, he would be the most qualified to add such enhancements.  It is well beyond my abilities.

-Dan
0 Kudos