Hi,
I have a LocalFeatureService that I have created with the path to my mpk. I would like to gather the layer names for each layer from the service. When I was working with the WPF SDK there is a FeatureLayers property that returns a collection of LayerDetails (ArcGIS Runtime SDK for Microsoft WPF - Library Reference ). How can I gather this information with the SDK for .Net?
Thanks,
Luke
Solved! Go to Solution.
I actually got this figured out. For anyone else looking for the same thing...the code sample below will get the FeatureServiceInfo which has a Layers property that returns the LayerServiceInfo.
var featureService = new LocalFeatureService(mpkPathText.Text);
await featureService.StartAsync();
if (featureService.Status == LocalServiceStatus.Running)
{
var layersUrl = featureService.UrlFeatureService + "/layers?f=json";
var webClient = new WebClient();
var stream = await webClient.OpenReadTaskAsync(layersUrl);
var serializer = new DataContractJsonSerializer(typeof(FeatureServiceInfo));
var result = serializer.ReadObject(stream);
}
Luke
Are you referring to the "GetAllDetails()" method? That's also there in the new SDK:
ArcGISDynamicMapServiceLayer.GetAllDetailsAsync Method
Btw, I would also suggest you take a look at the new Geodatabase support instead of using MPK files. It could mean you don't need to use local server, and you can render everything as feature layers are high performance. It might very well do everything you need.
Thanks for your quick response. I will definitely take a look at the new Geodatabase support. I am about to check out direct access of shapefiles as well!
Cheers,
Luke
I actually got this figured out. For anyone else looking for the same thing...the code sample below will get the FeatureServiceInfo which has a Layers property that returns the LayerServiceInfo.
var featureService = new LocalFeatureService(mpkPathText.Text);
await featureService.StartAsync();
if (featureService.Status == LocalServiceStatus.Running)
{
var layersUrl = featureService.UrlFeatureService + "/layers?f=json";
var webClient = new WebClient();
var stream = await webClient.OpenReadTaskAsync(layersUrl);
var serializer = new DataContractJsonSerializer(typeof(FeatureServiceInfo));
var result = serializer.ReadObject(stream);
}
Luke
That's a lot more involved way to do it, but it also the best and most efficient way. Nice work