Select to view content in your preferred language

Map Initialization Lifecycle

2336
2
06-23-2011 12:01 AM
Labels (1)
JH2
by
Emerging Contributor
Hi all,

As my map loads, I run through some initialization; applying the correct extent to the map and putting some data into a GraphicLayer.

Is there a standard way to check/listen for initialization? 

I've been using the

Map.Initialized


event but, for example, the Map.SpatialReference (which I need to know to calculate the extent) and the Map.Layers aren't ready at this point.  I've also tried the

Map.Layers.LayersInitialized


event, which correctly lets me know when the Graphics layer is ready for data, but there is no Map.Layers.IsInitialized property for me to check.  (I'm building Behaviors so I don't necessarily know if I've been attached at init or at a later stage.)  It also seems a bit weird to check this when waiting for the Map.SpatialReference to be ready, but I guess that perhaps this value comes from the Layers?

Just wondered if there was a resource describing this lifecycle or any recommendations on how to deal with it?  Any thoughts or suggestions gratefully received!!

Thanks,
James
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor

It also seems a bit weird to check this when waiting for the Map.SpatialReference to be ready, but I guess that perhaps this value comes from the Layers?


If you don't set the map spatial reference, this one is coming from the layers, and so we need to wait for them to be initialized.


but there is no Map.Layers.IsInitialized property for me to check

Right, but you can check the 'IsInitialized' property of each layer inside the collection.

Subscribing to Map.Layers.LayersInitialized is one way to do what you want, another would be to subscribe to Map.PropertyChanged and test whether the "SpatialReference" property has changed.
0 Kudos
JH2
by
Emerging Contributor
That makes sense and clears it up - just wanted to make sure I hadn't missed anything!

Cheers,
James
0 Kudos