Filter SceneLayer with FeatureFilter

Filter (masking) features is useful in urban planning. In this sample users can hide buildings and trees by drawing a masking polygon, polyline or points with buffers.

The polygon, polyline or point used for filtering is drawn using the SketchViewModel. We define it by passing in the view and a GraphicsLayer where the polygon, polyline or point is drawn. Optionally we can set a symbol for the polygon, polyline or point:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// use SketchViewModel to draw polygons that are used as a filter
const sketchViewModel = new SketchViewModel({
  layer: graphicsLayer,
  view: view,
  polygonSymbol: {
    type: "polygon-3d",
    symbolLayers: [
      {
        type: "fill",
        material: {
          color: [255, 255, 255, 0.8]
        },
        outline: {
          color: [211, 132, 80, 0.7],
          size: "10px"
        }
      }
    ]
  }
});

Spatial filtering can be easily achieved by setting a FeatureFilter on a SceneLayerView:

1
2
3
4
buildingLayerView.filter = new FeatureFilter({
  geometry: polygon,
  spatialRelationship: "disjoint"
});

Currently for 3D object SceneLayerViews spatial FeatureFilter only works when spatialRelationship is one of contains, intersects, disjoint.

Another way to filter a scene layer is using a SceneFilter. This filter is set on the SceneLayer instead of the SceneLayerView. It accepts several polygons and can be persisted in WebScenes or on the SceneLayer. For more information, see this sample: Filter SceneLayer with SceneFilter.

Other helpful resources

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

The developer dashboard has moved

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close