Select to view content in your preferred language

Dynamic Service Layer Loaded?

765
2
11-17-2010 06:32 AM
MatthewPilgrim
Regular Contributor
Hi,
How do I tell when a ArcGISDynamicMapServiceLayer has loaded all the Layers in the LayerInfo Array?

I am trying to set the VisibleLayers property but this doesn't seem to work by the time the Layer.Initialized event fires.  If I wait a while and the run the same code (presumably after the layers are fully loaded) then it works.


Any advice?

Thanks in advance, Matt
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
When all layers of a map are initialized, the event 'LayersInitialized' fires on LayerCollection object.

So you can hook up with a code like :
 
myMap.Layers.LayersInitialized += ....


That being said it's strange that your code is not working by the time the Layer.Initialized event fires. In my opinion, it should work. What is doing your code exactly?
0 Kudos
MatthewPilgrim
Regular Contributor
Hi,

I am trying to set the VisibleLayers property in MapPrinter.InitializePrintMap (in your Print example). 

if (toLayer != null)
    {
     toLayer.InitializationFailed += (s, e) => { }; // to avoid crash if bad layer
                    toLayer.Initialized += (s, e) => {

                                  CopyLayerVisibility((Layer)s, toLayer);

                    };

     printMap.Layers.Add(toLayer);
    }


This loops though the feature layers in the main maps dynamic layer building an list of visible ones and then sets them on the print maps dynamic layer [ToLayer].  i.e.

ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer printdynamicService = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)ToLayer;
                    printdynamicService.VisibleLayers = visibleLayerList.ToArray();


This doesn't work when the printmap is first initialized.  If I call the same code sometime later from PreparePages (called by clicking the scale fixed checkbox) then it works.

Matt
0 Kudos