setFeaturesVisible not working

377
3
04-23-2020 08:01 AM
MKa
by
Occasional Contributor III

I have a list of features that I want to set the visibility on for on a feature layer.  I don't want to change the definition expression because I requery the layer periodically to get the latest attributes, I have to remove and readd the definition query.

I do something like this, but I cant seem to get it to work.

property var allFeatures: ({})
property var searchFeatures: ({})
property Layer queryLayer: null

onLengthChanged: {
                        searchFeatures = {}
                            for (var i = 0; i < listModelFields.count; i++) {
                               searchFeatures[id] = features[id]
}
                        queryLayer.setFeaturesVisible(searchFeatures)
                    }


The above snippet just shows where i am trying to apply the setFeaturesVisible.  I basically have a search bar, that when the length changes, I want the visible features to change with the filter this search bar performs on the model.  But with my list of features I cant seem to get them show or hide, in fact the code actually breaks.  Has anyone tried this function.

0 Kudos
3 Replies
JamesBallard1
Esri Regular Contributor

Hi M Ka‌,

   Can you try using list objects in your code?

This is an object

searchFeatures = {}

This is a list/array

searchFeatures = []

Please try that and let us know if that gets it working for you.

0 Kudos
MKa
by
Occasional Contributor III

I tried using both ways and neither worked.  I feel like I am missing something, but I cant find an example of this anywhere.  I need to be able to do this as I just want features not to be visible and not remove them from the definition query.  Does anyone know of some code examples of this anywhere?  I looked through the entire qt samples and a quick internet search and I came up with nothing.  For now I have to remove the definition query before I search and refresh my layer, then add the query back in after the search returns all the features, this is suboptimal at best.

0 Kudos
JamesBallard1
Esri Regular Contributor

M Ka‌,

     There is an error in our documentation for that method. Please accept my apologies for this error. I also apologize for the delay in getting back to you on this.

The method you're calling has a second argument that is not documented properly.

void FeatureLayer::setFeaturesVisible(list<Feature> features, bool visible)

Does that work if you pass the second arg?

FeatureLayer QML Type | ArcGIS for Developers 

We'll get this fixed up asap.

0 Kudos