Select to view content in your preferred language

FeatureLayer. queryFeatures result is not return all attributes,How to set outFields?

823
2
07-06-2023 06:02 PM
mqllin
by
Occasional Contributor

FeatureLayer. queryFeatures result is not return all attributes,How to set outFields?

I used ArcGis Kotlin SDK 200.1.0

For example this image:

This FaetureLayer have fields:"objectid","sbm","code","name","dwdm","code","hzjh".But when I run queryFeatures or selectFeatures,only return fields "code","name" and "objectid".

I found that the outFields in QueryParameters is not set by internal methods.

How can I get the full attribute result featrues?


val queryParams = QueryParameters().apply {
whereClause = "name LIKE '%$name%'"
}

// layer.featureTable?.queryFeatures(queryParams)
val queryResult: Result<FeatureQueryResult> = featureTable.queryFeatures(queryParams)
// val queryResult: Result<FeatureQueryResult> = (layer as FeatureLayer).selectFeaturesWithFields()

queryResult.onSuccess { res ->
Log.d("fields", res.fields.toString())
res.fields.forEach {
Log.d("for", it.toJson())
}
res.forEach {
it.attributes.forEach {
Log.d("attributes", "${it.key}-${it.value}")
}
}
val features = res.toList()
if (features.isNotEmpty()) {
features[0].attributes.forEach {
Log.d("features", "${it.key}-${it.value}")
}
}
val layerResult = object : SearchFeatureSet {
override var name = layer.name
override var layer = layer
override var features = features
override var showMore = false
}
results.add(layerResult)
layer.clearSelection()
}

mqllin_0-1688691178319.png

Tags (1)
0 Kudos
2 Replies
RamaChintapalli
Esri Contributor

Hi,

You can use the following method to receive all the features loaded, alternatively you can also individually load a specific feature to load only its attributes. 

 

 

suspend fun queryFeatures(
    parameters: QueryParameters, 
    queryFeatureFields: QueryFeatureFields
): Result<FeatureQueryResult>

 

 

 and use QueryFeatureFields.LOADALL.

Thanks
Rama

0 Kudos
mqllin
by
Occasional Contributor

Thank you for your help,I have modified my request code,and now I can query all the attributes!

I got FeatureLayer.FeatureTable as to ServiceFeatureTable

```

val queryResult: Result<FeatureQueryResult> = (featureTable as ServiceFeatureTable).queryFeatures(queryParams,QueryFeatureFields.LoadAll)

```

In addition, one thing I want to ask, why not allow Settings in the FeatureTable QueryFeatureFields?

 
0 Kudos