How to determine extent of a dynamic shapefile layer

2659
3
Jump to solution
10-15-2014 12:45 PM
LukePatterson
New Contributor III

I am adding a shapefile to my map as a dynamic map service layer just as is done in the DynamicLayerAddData sample.

The FullExtent property of my ArcGISDynamicMapServiceLayer is returning the full extent of the layers within the "water-distribution-network.mpk" instead of the extent of my shapefile layer (took me a bit figure out why MapView.SetView was taking me to a seemingly random place in Alabama instead of to my newly added shapefile ). Any suggestions on other ways of getting the actual extent of this type of layer?

Reply
0 Kudos
1 Solution

Accepted Solutions
MortenNielsen
Esri Frequent Contributor

Use the GetAllDetailsAsync and GetDetailsAsync(id) to get metadata for sub layers of an ArcGISDynamicMapserviceLayer.

ie

      var extent = (await layer.GetDetailsAsync(0).Extent;

On a side-note, don't create a feature layer just to create a table. You can initialize the table by itself. On a second not, don't create a table just to get it's metadata. Both of these are quite expensive operations and should be avoided if you don't need to access data and/or render it.

View solution in original post

3 Replies
LukePatterson
New Contributor III

After messing around with regards to this for a bit, I came up with a way in which I can determine the FullExtent of my shapefile.

if (layer is ArcGISDynamicMapServiceLayer)

{

       var dynamicLayer = layer as ArcGISDynamicMapServiceLayer;

       var featureLayer = new FeatureLayer(new ServiceFeatureTable() {

                                               ServiceUri = dynamicLayer.ServiceUri  + "/dynamicLayer",

                                               Source = dynamicLayer.DynamicLayerInfos[0].Source                                                                                             });

        await featureLayer.InitializeAsync();

        extent = featureLayer.FullExtent;

}

else

{

       extent = layer.FullExtent;

}

Reply
0 Kudos
MortenNielsen
Esri Frequent Contributor

Use the GetAllDetailsAsync and GetDetailsAsync(id) to get metadata for sub layers of an ArcGISDynamicMapserviceLayer.

ie

      var extent = (await layer.GetDetailsAsync(0).Extent;

On a side-note, don't create a feature layer just to create a table. You can initialize the table by itself. On a second not, don't create a table just to get it's metadata. Both of these are quite expensive operations and should be avoided if you don't need to access data and/or render it.

View solution in original post

LukePatterson
New Contributor III

Thanks Morten! That's exactly what I needed.

Reply
0 Kudos