AnsweredAssumed Answered

Hide polygons resulting from a spatial query

Question asked by dpetrova on Jan 30, 2019
Latest reply on Mar 14, 2019 by rscheitlin

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?

Outcomes