Select to view content in your preferred language

ArcGISDynamicMapServiceLayer.FullExtent is Null

2371
6
11-04-2012 11:54 AM
AshakaThakore
Emerging Contributor
i am trying to add a dynamic map service layer, and zoom to that layer, but the full-extent of the layer it is always null...

                ArcGISDynamicMapServiceLayer mylayer = new ArcGISDynamicMapServiceLayer();
                mylayer.DisableClientCaching = true;//recommended
                mylayer.Url = DynamicUrl ;
                mylayer.ID = "CURRENTLAYER";

               
                int totlayers = this.MyMap1.Layers.Count;
                this.MyMap1.Layers.Insert(totlayers, mylayer);
                
                Envelope anenv = mylayer.FullExtent;
                 MyMap1.ZoomTo(anenv);
//anenv is always null

how do i handle that?

thanks a lot
0 Kudos
6 Replies
deleted-user-ATjHIWsdQYmT
Deactivated User
You have to initialize your DynamicMapServiceLayer in order to be able to get it's full extent.  There is an Initialize() method to call.  Then you have to add an event handler to handle the initialized event.  In that handler, you can zoom the map to the layer's extent.
0 Kudos
AshakaThakore
Emerging Contributor
Do I have to initialize after inserting the layer to the map or before ?

ArcGISDynamicMapServiceLayer mylayer = new ArcGISDynamicMapServiceLayer();
mylayer.DisableClientCaching = true;//recommended
mylayer.Url = DynamicUrl ;
mylayer.ID = "CURRENTLAYER";


mylayer.Initialized += new EventHandler<EventArgs>(mylayer_Initialized);

int totlayers = this.MyMap1.Layers.Count;
this.MyMap1.Layers.Insert(totlayers, mylayer);

mylayer.Initialize() ;

Please help.. thanks a lot
0 Kudos
deleted-user-ATjHIWsdQYmT
Deactivated User
Do I have to initialize after inserting the layer to the map or before ?

ArcGISDynamicMapServiceLayer mylayer = new ArcGISDynamicMapServiceLayer();
mylayer.DisableClientCaching = true;//recommended
mylayer.Url = DynamicUrl ;
mylayer.ID = "CURRENTLAYER";


mylayer.Initialized += new EventHandler<EventArgs>(mylayer_Initialized);

int totlayers = this.MyMap1.Layers.Count;
this.MyMap1.Layers.Insert(totlayers, mylayer);

mylayer.Initialize() ;

Please help.. thanks a lot


I'd probably do it after you insert it into your map.  Are you trying to insert the layer at a specific place in your layer order?  Otherwise you can just use MyMap.Add(mylayer);
0 Kudos
AshakaThakore
Emerging Contributor
I'd probably do it after you insert it into your map.  Are you trying to insert the layer at a specific place in your layer order?  Otherwise you can just use MyMap.Add(mylayer);


Yes, i am trying to insert at particular location

here on this link i found that i should insert after initialize is done

http://forums.arcgis.com/threads/59382-Layer-not-initialized?highlight=arcgis+layer+initialize%28%29

So It did work...

now the problem is i want to zoom to that layer after its initialized and my my map's SRID is 102100
And my layer's projection/SRID is different and if i do - mymap.zoomto(mylayer.fullextent) it zooms to wrong place bcos SRID are different

pl help

how should i project that fullextent to srid 102100 or how should i handle this problem

thanks a lot
0 Kudos
deleted-user-ATjHIWsdQYmT
Deactivated User
You can use a GeometryService to project your envelope from your layer's spatial reference to 102100.  Here's the API documentation with example:
http://resources.arcgis.com/en/help/silverlight-api/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Tas...

Note the input has to be a graphic so you can just create a new graphic using the extent of your envelope.  You'll raise a "ProjectCompleted" event.  From there you can take the result and use that to zoom to your layer extent.  That'll work.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
You can find a sample of what Andrew mentioned here.

You have to wire up the 'ZoomToFullExtent' handler to the  'Initialized' layer event.
The handler projects the fullextent to the map spatial reference coordinates (using a geometry service if needed).
0 Kudos