Hello! I have *.mmpk files on my Map and use
featureLayer.setFeaturesVisible()
method for making my features visible or hidden.
But in case if I click on the map and try to find feature by coordinates, I receive a hidden feature. I need to avoid such clicks. How can I determine the visibility of a feature?
Hi,
"click on the map and try to find feature by coordinates"
Can you provide more info (or code snippet) on how you are finding features by coordinates?
GeoView.identifyLayersAsync usually does a hit test on the layers based on features visibility which should avoid returning invisible features.
Here is a sample on that perform identify on layers,
https://github.com/Esri/arcgis-runtime-samples-android/tree/main/java/identify-layers
Thanks
Rama
Hi, @RamaChintapalli !
I use this code to get features. I can't use your method, because I need to use query for my feature
private fun getFeaturesByQuery(
query: QueryParameters,
doneCallback: (FeatureLayer, List<Feature>?) -> Unit
) {
if (mapView.map == null || mapView.map.operationalLayers.isNullOrEmpty()) {
return
}
val topLayer = mapView.map.operationalLayers[0] as FeatureLayer
val future = topLayer.featureTable.queryFeaturesAsync(query)
future.addDoneListener {
val result = future.get()
val resultIterator = result.iterator()
if (resultIterator.hasNext()) {
doneCallback.invoke(topLayer, result.toList())
} else {
doneCallback.invoke(topLayer, null)
}
}
}
Hi,
If you are performing query and the query is returning features from the GeodatabaseFeatureTable that are not visibly rendered by FeatureLayer, then likely that your FeatureLayer has a definition expression defined on it. If so, can you apply the same filter on the query parameters whereClause while querying the features from the GeodatabaseFeatureTable which can restrict the features returned.
Thanks
Rama
@RamaChintapalli could you tell me, how can I do it? Because I didn't find any info in QueryParams for visibility of Features
The visibility of Features is controlled by FeatureLayer. GeodatabaseFeatureTable table on the other hand has all the features in the table as authored. And the individual features doesn't provide any information of its Visible state.
From what I understood from your issue - my suggestion was, if FeatureLayer is already filtering the visible features (either by definitionExpression or FeatureLayer.setFeaturesVisible() method) , then we should be able to apply the same filtering while querying the features from GeodatabaseFeatureTable using whereClause.
Thanks
Rama
@RamaChintapalli it sounds pretty strange. Yes, you can control the visibility of Features with FeatureLayer, but what is the reason not to add the getter for an exact Feature?
For now, I can't add an additional query to whereClause, because I don't store the previous filter. So... If there are no solutions, I need to add a workaround to check the visibility.
Also, I need to check the visibility of Feature when I click on the Map. I use this method:
private fun getFeatureByPoint(
screenPoint: Point,
doneCallback: (FeatureLayer, Feature?) -> Unit
) {
val mapPoint = mapView.screenToLocation(screenPoint)
val query = QueryParameters()
query.geometry = mapPoint
getFeatureByQuery(query, doneCallback)
}
After that, I get invisible Feature. So I need somehow put additional whereClause from the previous query.
Maybe is better to add a getter, sounds pretty logical for me.
As I see it, your method `getFeatureByPoint` is pretty much doing what an identify would do. Additionally identify would also perform hit test to make sure the feature is visible.
I will also take it to the team on providing an option to know the visibility state of feature in a feature layer. As far having a property on the feature itself will be discussed further. From the way API is designed features can work independent of rendering of the layer for applications that do not have any rendering needs. So it may be weighed in further in the discussion.
Thanks
Rama