Hello everyone,
I'm working with Arcgis JS API 4.25.
I'm trying to filter a FeatureLayer based on this concept:
Apply effects to features
Since I'm using a SceneView, I can't use featureEffect.filter so i'm using filter directly on the featureLayerView, and it seems to work just fine.
The issue I have is with the buffer. The example works fine
But when I try to replicate it, there is this strange gap between the visual of the geometry and the actual geometry used to filter the features:
I'm doing nothing more than the example do :
function updateFilter() {
let featureFilter = null;
if (filterGeometry) {
let bufferGeometry = filterGeometry;
if (distance > 0 && filterGeometry) {
bufferGeometry = geometryEngine.buffer(filterGeometry, distance, unit);
bufferLayer.graphics.getItemAt(0).geometry = bufferGeometry;
} else {
bufferLayer.graphics.getItemAt(0).geometry = null;
}
featureFilter = {
geometry: bufferGeometry,
spatialRelationship: spatialRel,
distance,
units: unit,
};
}
if (featureLayerView) featureLayerView.filter = featureFilter;
}
Do you have any ideas what would be the problem ?
I'm guessing maybe something wrong about a wkid ?
Solved! Go to Solution.
I found what was the issue.
I was using this as a filter :
featureFilter = {
geometry: bufferGeometry,
spatialRelationship: spatialRel,
distance,
units: unit,
};
But the bufferGeometry was already at distance from the initial geometry (filterGeometry).
So using a distance around the bufferGeometry was wrong.
I should have used :
featureFilter = {
geometry: bufferGeometry,
};
Such a dumb mistake ...
Thanks for your time.
It's a guess. Please let me know if it helps:
Since it works, but not at the right area,
maybe it is worth to use - await geometryEngineAsync.geodesicBuffer
What is the spatialReference of your map/scene ? Did you try using geometryEngine.geodesicBuffer instead of geometryEngine.buffer ?
I found what was the issue.
I was using this as a filter :
featureFilter = {
geometry: bufferGeometry,
spatialRelationship: spatialRel,
distance,
units: unit,
};
But the bufferGeometry was already at distance from the initial geometry (filterGeometry).
So using a distance around the bufferGeometry was wrong.
I should have used :
featureFilter = {
geometry: bufferGeometry,
};
Such a dumb mistake ...
Thanks for your time.