Temporarily disable REST export on layerItemViewModel.IsEnabled?

2239
0
07-08-2015 10:54 AM
philippenn
Occasional Contributor

I have some code for persisting and restoring the Legend after the initial map has loaded.

Initially I was using ArcGISDynamicMapServiceLayer.VisibleLayers only, which works in terms of the layers on/off, but it does not store checked/enabled sublayers. So if a group layer is unchecked but all of the sublayers are checked, when restoring the view both group and sublayers are unchecked. Not the desired behavior.

So after setting the VisibleLayers I have to iterate through each Legend.LayerItemViewModel and restore its IsEnabled state. This works just fine but every time I call IsEnabled a full REST export happens behind the scenes, regardless of whether there is any change. Given that I'm only restoring IsEnabled for unchecked (not visible) ascendants, this is not only pointless but takes a lot of time. One unchecked group layer with 70 checked sublayers will be 70 REST export methods being called -- and they're all the same set of VisibleLayers because the group layer is unchecked.

Is there any way to temporarily unhook the Legend? I've tried Legend.Map=null, then calling the code above and then reattaching but still the same # of calls are generated.

cheers

Phil

Tags (2)
0 Kudos
0 Replies