使用 SceneLayer 按几何过滤要素

尝试一下在线预览

过滤(屏蔽)要素在城市规划中是有用的。在这个示例中,用户可以通过绘制一个带有缓冲区的掩蔽多边形、折线或点来隐藏建筑物和树木。

用于过滤的多边形、折线或点是使用  SketchViewModel 绘制的。我们通过传入绘制多边形、折线或点的视图和 GraphicsLayer 来定义它。我们还可以为多边形、折线或点设置符号:

                    
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"
        }
      }
    ]
  }
});

通过在 SceneLayerView 上设置一个过滤器 ,可以很容易地实现空间过滤:

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

目前对于 3D 对象 SceneLayerViews,空间 FeatureFilter 仅当 spatialRelationshipcontainsintersectsdisjoint 之一时才有效。

其他有用的资源

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

The action has been successful