Good Day
I have a situation where I need to hide several features in the Stream Layer, but I can't set a definitionExpression, so I'm setting the layer's featureEffect:
const featureFilter = new FeatureFilter({
where: featureQuery
});
layer.layer.featureEffect = new FeatureEffect({
filter: featureFilter,
excludedEffect: "opacity(0%)"
});
This works, and the features “disappear”. The issue I have, they still respond to the “hitTest”, so if I have a sketchWidget active and do something like:
this.sketchWidgetPointerUpEvent = this._view.on("pointer-up", (event) => {
this._view.hitTest(event).then(async (response) => {
if (response.results.length && this.lassoSet) {
this.lassoSet = false;
this._view.graphics.removeAll();
const geometries = response.results.map((graphic, index: number) => {
if (graphic.graphic.geometry) {
return graphic.graphic.geometry
}
});
const queryGeometry = await geometryEngineAsync.union(geometries);
this.selectFeatures(queryGeometry);
}
});
});
My question is, how do I stop the excluded features from being selectable? Is there a better way to query the features, and I don't think using the layerView.queryFeatures would work because that would only consider what's in the active view, not what is outside the view? Is there a way to look at the effect of the feature? If I do use layerView.queryFeatures, could I force it to look at the entire map instead of the view (I don't think so).
Thanks for any help provided.
Thanks
Hi there,
Features excluded from the feature effect still participate in the hitTest because they remain visible on the map. To resolve this, apply the filter directly to the StreamLayerView, since you are setting the excluded features to be fully opaque. This ensures that the filtered-out features are not included in the hitTest results.
To do this, you need to obtain an instance of the layerView and set the filter on it, as demonstrated in the following pseudo code:
// get the layer view instance
const layerView = await view.whenLayerView(layer);
// later in the code
// set filter on the stream layer view
layerView.filter = featureFilter;
I modified the sample you are using to showcase this: https://codepen.io/U_B_U/pen/XJWOoMY?editors=1000
Good Day
I can't use the layerView query because there is no guarantee the layerView is zoomed out so the extent captures the entire map. What I opt'd to do instead is record the ID of all features that I excluded. When I'm going to select them, by adding a graphic highlight, check the list, and if the matching index of the ID is -1, I know it's not excluded.
I think it's the best workaround. Is there any way to query a layerView so it considers the entire map? I know you can pass a geometry, could I use that to override the visible area, and return everything?
Using the layerView would be very helpful, but I don't think it will work for my use case because I don't know what the user is looking at.
Thanks
From your description, it seems like you're querying features and using featureEffect to display the results of the query. Then, you're using hitTest to highlight features that meet the included effect criteria. If you're relying on hitTest to highlight features, you'll only be interacting with those within the current map extent. I may be missing some details—could you clarify how you plan to select features outside the map extent using hitTest? In any case, your workflow is acceptable.