Select to view content in your preferred language

... about layer isinitialized properties

855
4
10-03-2010 05:02 AM
MarcoRosa
Emerging Contributor
hi friends,
hi have to add on map a dynamic map service layer ....

<esri:ArcGISDynamicMapServiceLayer ID="dinamico"
                    Url="http://myserver/ArcGIS/rest/services/test/MapServer" InitializationFailed="ArcGISDynamicMapServiceLayer_InitializationFailed"/>

happens that .... when i stop the services and start the application .... InitializationFailed is fired correctly.
Buot later .... if i do

   private void button1_Click(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < MyMap.Layers.Count; i++)
            {
                MessageBox.Show(MyMap.Layers.ID+" - "+ MyMap.Layers.IsInitialized);
            }
        }

isinitialize properties is true and layer is added on map but not visible ....... This is strange because this value could be false bacause the layer is not initialized ( and then could not be added on map  )
it's true ?

What is my error ?

thank you as usual
ciao GD
0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor
You did not do anything wrong. If you also subscribe to Initialized event, you will also notice that the ArcGISDynamicMapServiceLayer went through the initialization process, thereby setting IsInitialized property to true. This property only tells you that the layer has attempted to initialize. If there were any error during this stage, the layer's InitializationFailure will not be null.  You can test this by setting an invalid URL.
0 Kudos
VickyP
by
Emerging Contributor
Hi Jenniferdnery,

     I also want to check if the mapservice which I am consuming in my application consists of layers that does not have a datasource assigned, How can I do this, if my mapservice does not have  a datasource assigned to it? as you know that isinitialized method of Dynamic Service is not working. Please suggest any other solution that uses some different methods and properties.


Thanks & Regards,
Varun
0 Kudos
DominiqueBroux
Esri Frequent Contributor

as you know that isinitialized method of Dynamic Service is not working.

What do you mean?

As Jennifer mentionned, this property only tells you that the layer has attempted to initialize.

To know if the initialization failed, you can use the property InitializationFailure, if it's not null, it means that the initialization failed.

So the possible combinations are:
   - IsInitialized = false : the layer is not initialized yet
   - IsInitialized = true and InitializationFailure = null : the layer has initialized correctly
   - IsInitialized = true and InitializationFailure != null : initialization is over but there was a failure
0 Kudos
VickyP
by
Emerging Contributor
What do you mean?

As Jennifer mentionned, this property only tells you that the layer has attempted to initialize.

To know if the initialization failed, you can use the property InitializationFailure, if it's not null, it means that the initialization failed.

So the possible combinations are:
   - IsInitialized = false : the layer is not initialized yet
   - IsInitialized = true and InitializationFailure = null : the layer has initialized correctly
   - IsInitialized = true and InitializationFailure != null : initialization is over but there was a failure


Hi dbroux,

  Thanks for replying, IsInitialized is not working means that even if the .mxd doc. consists of layers whose datasource is not set, then it shows true, thats why I have written its not working, I want a solution that will give me an answer that the mapservice which I am loading consists of layers without datasource, I found the answer in

ArcGISDynamicMapService lyr = sender as ArcGISDynamicMapService();
if lyr.layers == null then it gives indication that .mxd doc. consists of layers whose datasource is not set, if it is not null then it gives indication that .mxd doc. consists of layers whose datasources are set
0 Kudos