0

I just updated my ArcGis sdk to use sdk version 100.2.1.

Previously to get the layer name I was using

AGSFeatureLayer *featureLayer = (AGSFeatureLayer *) layer;
layerName = featureLayer.serviceLayerName

and now In the sdk 100.2.1 there is no parameter name

layerName = layer?.name

But it returning the different string

in 10.2.1 it is returing POI and in 100.2.1 it is returning Position Of Images

I have a backed loagic already implemented so is there any way to get the same service name in run time 100 ?

Parv Bhasker
  • 1,773
  • 1
  • 20
  • 39

2 Answers2

0

Looks like you want the service's name and not the layer's name:

layerName = (layer?.featureTable as? AGSServiceFeatureTable)?.tableName

If you are going to be working with offline workflows, or you're not sure and want to future-proof yourself in case that happens down the line, you can be a little broader in your scoping (see the class hierarchy diagram here) and use:

layerName = (layer?.featureTable as? AGSArcGISFeatureTable)?.tableName

Update: Note, as you mentioned in your response, you need to make sure the feature table is loaded, so something like this is likely more appropriate:

let serviceLayerTable = layer?.featureTable as? AGSServiceFeatureTable
serviceLayerTable?.load(completion: { error in
    guard error == nil else {
        print("Error loading table: \(error!.localizedDescription)")
        return
    }
    if let layerName = serviceLayerTable?.tableName {

    }
})

You can read from the layerInfo if you like, but the tableName property should work for you (once the table is loaded :)).

Nixta
  • 464
  • 2
  • 10
  • thnks but i also tried this. It is returning empty string. I just figure out a solution for this. – Parv Bhasker Jun 07 '18 at 05:42
  • Ah, my oversight. Sorry. Yes, you should make sure the table is loaded before reading the name. I'll update my reply. – Nixta Jun 07 '18 at 10:49
0

While doing research I found that in the arcgis sdk 10 for android we are getting the service name from the layerInfo parameter of feature layer but in ios there is not any layerInfo parameter and we have a direct parameter serviceLayerName to get the service name of layer.

So i found that in ArcGis sdk 100 arcgis introduce the layer info parameter in feature layer.

let serviceFeatureTable = featureLayer?.featureTable
serviceFeatureTable.load { (error) in
     if let layerName = serviceFeatureTable.layerInfo?.serviceLayerName {

     }
}
Parv Bhasker
  • 1,773
  • 1
  • 20
  • 39