What is the proper way to enumerate layers in MPK package generate from a personal geodatabase without using a MapView control? All the examples use the MapView or hard-code an index of the layer needed. Here is code (VB.NET):
Dim map As Esri.ArcGISRuntime.LocalServices.LocalFeatureService = _ Await Esri.ArcGISRuntime.LocalServices.LocalFeatureService.StartAsync(mpkPath) Dim i As Integer = 0 Do While True Dim sfTable As Esri.ArcGISRuntime.Data.ServiceFeatureTable = Nothing Try sfTable = Await Esri.ArcGISRuntime.Data.ServiceFeatureTable.OpenAsync(New Uri(map.UrlMapService & "/" & i)) Catch ex As Exception sfTable = Nothing End Try If sfTable Is Nothing Then Exit Do End If ' Do something with sfTable i += 1 Loop
Is this the proper way of enumerating until you get a 404 error when you're passed the last index ?
Thanks in advance,
Mark Oberg
Solved! Go to Solution.
Hi Mark -
Once you have a layer from the local service, you can use the ServiceInfo property of the layer to get details about the service.
The following example creates a dynamic map service layer using the URL of the local service. It then reads the service info and loops thru all layers in the service to find layer ID and name.
Dim localService As LocalFeatureService = Await LocalFeatureService.StartAsync(mpkPath)
Dim dynLayer As ArcGISDynamicMapServiceLayer = New ArcGISDynamicMapServiceLayer(New Uri(localService.UrlMapService))
Await dynLayer.InitializeAsync()
Dim serviceInfo As MapServiceInfo = dynLayer.ServiceInfo
Dim layerInfo As IReadOnlyCollection(Of LayerServiceInfo) = serviceInfo.Layers
For Each info As LayerServiceInfo In layerInfo
Dim id As Integer = info.ID
Dim name As String = info.Name
Next
You could do the same thing with ServiceFeatureTable (sfTable variable in your example) - initialize a service feature table with the first table in the package, then read the service info to determine what else is available.
Hope that helps, Thad
Hi Mark -
Once you have a layer from the local service, you can use the ServiceInfo property of the layer to get details about the service.
The following example creates a dynamic map service layer using the URL of the local service. It then reads the service info and loops thru all layers in the service to find layer ID and name.
Dim localService As LocalFeatureService = Await LocalFeatureService.StartAsync(mpkPath)
Dim dynLayer As ArcGISDynamicMapServiceLayer = New ArcGISDynamicMapServiceLayer(New Uri(localService.UrlMapService))
Await dynLayer.InitializeAsync()
Dim serviceInfo As MapServiceInfo = dynLayer.ServiceInfo
Dim layerInfo As IReadOnlyCollection(Of LayerServiceInfo) = serviceInfo.Layers
For Each info As LayerServiceInfo In layerInfo
Dim id As Integer = info.ID
Dim name As String = info.Name
Next
You could do the same thing with ServiceFeatureTable (sfTable variable in your example) - initialize a service feature table with the first table in the package, then read the service info to determine what else is available.
Hope that helps, Thad