0

I have a feature service hosted on ArcGIS Online that has a dynamic number of point and polyline layers under it. To retrieve a single feature layer in this feature service, you simply specify the index ...FeatureServer/0 as the url and wrap in the below objects. These provide all the geographical data and metadata about the layer.

const val toursUrl = "https://services1.arcgis.com/1234/ArcGIS/rest/services/XXX/FeatureServer/0"
val townTourFeatureTable = ServiceFeatureTable(toursUrl)
val featureLayer = FeatureLayer.createWithFeatureTable(hvTourFeatureTable)

But I am trying to access the feature server and get a list of all of the layers like the one above.

The above objects do not work with a link without the index at the end, and neither does ArcGISMapImageLayer, which gave an error that "map" is not a supported service. I can't seem to find a page in the documentation that discusses feature servers, not a specific layer in the feature server.

These have properties called sublayerContents or something similar, but all give null values or empty arrays.

Is this something supported by ArcGIS Maps SDK for Kotlin? The JavaScript SDK has what I'm looking for but I can't use it because I am developing this for Android and iOS.

1 Answer 1

0

ServiceGeodatabase is what I was looking for. It contains a list called layerInfos that populates once load() is called.

var tours by remember { mutableStateOf(listOf<IdInfo>()) }
val scope = rememberCoroutineScope()
scope.launch {
    val portal = Portal(
        url = "https://www.arcgis.com",
        connection = Portal.Connection.Anonymous
    )
    val toursItem = PortalItem(
        portal = portal,
        itemId = "ITEM_ID"
    )
    toursItem.load()
    val geodatabase = ServiceGeodatabase(toursItem)
    geodatabase.load()
    geodatabase.serviceInfo?.let {
        tours = it.layerInfos
    }
}

I found this by searching the API reference for a feature service (not layer) object, finding ArcGISFeatureServiceInfo. This object did not have a public constructor but the documentation mentioned

You can obtain the ArcGISFeatureServiceInfo from a loaded GeodatabaseSyncTask or from a loaded ServiceGeodatabase.

From there I found ServiceGeodatabase and passed in the portal item.

The reason that the documentation does not openly explain this is that adding a new layer to a feature service after it has been created is not easily done. The feature layers are meant to be created at the beginning and not fetched dynamically. So instead I put all of my layers into one, and used two tables to add metadata about the groups of points I was adding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.