HitTest able to select a feature with isn't visible

649
2
10-06-2021 09:36 AM
AndrewMurdoch1
Occasional Contributor II

Good Day

I have a map with many layers on it, when I turned off a layer by setting opacity to 0 in the feature query:

if (featureQuery.length > 0) {
this._view.whenLayerView(this._layers[prop][innerProp]).then((featureLayerView) => {
featureLayerView.effect = {
filter: {
where: featureQuery
},
excludedEffect: 'opacity(0%)'
};
});
} else {
this._layers[prop][innerProp].visible = false;
}



the layer disappears, but I'm still able to select the feature, the circle is not visible on the map

AndrewMurdoch1_0-1633535532542.png

I'm using ArcGIS Core 4.20.2, I'm doing a hittest to pick up the feature clicked, is there away to filter out features which aren't visible, or have an opacity of 0?

This is the main part of my query function:

try {
if (this._layers[prop][geometryProp]) {
if (this._layers[prop][geometryProp].visible) {
if (typeof this._layers[prop][geometryProp].createQuery === 'function') {
const query = this._layers[prop][geometryProp].createQuery();
query.where = 'ObjectID = ' + objectId;
query.outFields = ['*'];
query.returnGeometry = geometry;

this._layers[prop][geometryProp].queryFeatures(query).then((queryRes) => {
queryRes.features.map((feature) => {
if (geometry) {
if (feature.geometry) {
r(feature.geometry);
}
} else {
if (feature) {
r(feature);
}
}
});
});
}
}
}
} catch (error) {
console.log(error);
}

 Thanks

0 Kudos
2 Replies
JeffreyWilkerson
Occasional Contributor III

Maybe you could maintain a list of the loaded map feature layers, then if one is changed to have a transparency set to 0 you could remove it from this list (until it was set back I'm guessing).  Then when you called the query function you could check this list and not perform the query if the feature layer wasn't in it.  It just seems that if you control when a layer's transparency is turned off, then you should be able to track that and know which layers not to use in the query.

0 Kudos
AndrewMurdoch1
Occasional Contributor II

Thanks for the suggestion, I actually solved it by using .filter instead of .effect

featureLayerView.filter = new FeatureFilter({
where: featureQuery
})

If anyone else runs into this problem, trying using a Feature Filter instead...