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?
Solved! Go to Solution.
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.
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;
}
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.
Thanks Morten! That's exactly what I needed.