Hi ARCGIS/JS experts,
I have a bunch of web layers and want to hide all polygons that are intersect with a given geometry/other layer.
I filter these intersecting polygons using spatial query, but then I don't know how to hide them. I was thinking that can manipulate renderer of resulting polygons, something like: hide(), opacity = 0, visible=false... Or maybe I need filter only those that are not intersecting and render only them?
Here is my query:
view.whenLayerView(layer).then(function(layerView){
var query = layer.createQuery();
query.geometry = new Extent({
xmin: 6902682.7633,
ymin: -3519872.5095,
xmax: 11221869.7958,
ymax: -2276864.0272,
spatialReference: 102100
});
query.spatialRelationship = "intersects";
layer.queryFeatures(query).then(function(results){
for (var index in results.features) {
//hide as manipulate its rendering
}
// or something like layerView.highlight(results.features)
})
});
Is this right approach, or I need first to query polygons that are not intersecting and then add results to a new layer and render only them? In such case what should be query.spatialRelationship?
Solved! Go to Solution.
Daniela,
You would just query for the ObjectIds and then set the layer definition query to be :
"NOT ObjectID IN (" + QueryResultsArr.join() + ")"
Daniela,
You would just query for the ObjectIds and then set the layer definition query to be :
"NOT ObjectID IN (" + QueryResultsArr.join() + ")"
Thanks a lot, I haven't know about I can pass a query results to a definition expression
Daniela,
Not actually pass the query result but a SQL statement from the results.
Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.
A problem has appeared. When I'm working with feature layers the app performance is very poor, processing and loading FeatureLayer's is extremely slow. Therefore I've decided to work with MapImageLayer, which is loaded immediately. But now how to query sublayers of MapImageLayer for get those ObjectIds that are intersects with given extent?
Daniela,
When using a MapImageLayer for the visualization in the map you will use a QueryTask and Query classes to query the sublayer and return the ObjectIds