Cesium设置面Entity高亮显示
来源:直接复制网 时间:12-13
cesium怎么设置entity高亮呢? 以下是方法:
![](/uploads/2109/2_210928141933_1.gif)
参数描述:
- id: Entity实体id
- heightEntity:高亮结果Entity
- defaultLayer和tempLayer均是DataSource的集合
代码
- let heightEntity = null;
- HighlightPolygonEntity(id) {
- if (heightEntity) {
- defaultLayer.entities.remove(heightEntity);
- }
- if (!id) {
- return;
- }
- let e = tempLayer.entities.getById(id);
- heightEntity = defaultLayer.entities.add({
- polyline: {
- positions: e.polygon.hierarchy.getValue().positions,
- width: 10,
- material: new Cesium.PolylineGlowMaterialProperty({
- glowPower: 0.5, // 一个数字属性,指定发光强度,占总线宽的百分比。
- color: Cesium.Color.ORANGERED,
- }),
- clampToGround: true,
- },
- });
- window.viewer.dataSources.raiseToTop(defaultLayer);//设置defaultLayer置顶
- }
使用方法
- 高亮:HighlightPolygonEntity("id")
- 取消高亮:HighlightPolygonEntity(null)