Hello, I'm using this this guide to identify which layers were clicked on MapView.
it works perfectly for every layers I have except from Feature Collection Layers. where the attributes are in a feature table and not elements.
how do I get the attributes inside a feature table?
to identify layers:
fun identifyClickedLayerResults(point: android.graphics.Point, mMap: MapView, callback: (MutableList<IdentifyLayerResult>) -> Unit){
val TAG = "ClickedLayerResults"
var identifyLayerResult: MutableList<IdentifyLayerResult>
val identifyLayerResultsFuture = mMap
.identifyLayersAsync(point, 12.0, false, 5)
identifyLayerResultsFuture.addDoneListener {
try {
identifyLayerResult = identifyLayerResultsFuture.get()
callback(identifyLayerResult)
} catch (e: InterruptedException) {
Log.e(TAG, "Error identifying results: " + e.message)
} catch (e: ExecutionException) {
Log.e(TAG, "Error identifying results: " + e.message)
}
}
}
to get attributes:
fun layerDetails(forLayer: IdentifyLayerResult): ArrayList<Map<String, String>>{
val resultGeoElements = forLayer.elements
if (forLayer.layerContent.name == "Feature Collection"){
//doesn't work here
}
var mAttributesString = ArrayList<String>()
var layersAttributeList = ArrayList<Map<String, String>>()
if (!resultGeoElements.isEmpty()){
resultGeoElements.forEach {
if (it is ArcGISFeature){
val mArcGISFeature = it as? ArcGISFeature
mAttributesString.add(mArcGISFeature?.attributes.toString())
var mTempMap = mutableMapOf<String, String>()
mArcGISFeature?.attributes?.forEach {
if (!it.value.toString().isEmpty() && !it.key.toString().isEmpty()
&& !it.key.toString().contains(".FID"))
mTempMap[it.key.toString()] = it.value.toString()
}
layersAttributeList.add(mTempMap)
}
}
}
return layersAttributeList
}
what i got now :
private fun featureCollectionDetails(forLayer: IdentifyLayerResult){
var featureCollectionLayer = forLayer.layerContent as FeatureCollectionLayer
var mFeatureTable = featureCollectionLayer.layers[0].featureTable
}
the code is in kotlin, its ok if the answer will be in java