删除cesium js中的Polyline

Cha*_*Raj 6 cesiumjs

如何删除 cesiumjs 中的折线,

var p = this.viewer.entities.add({
    polyline: {
        material: new Cesium.PolylineGlowMaterialProperty({
            glowPower: 0.7,
            color: Cesium.Color.ORANGE.withAlpha(0.7)
        }),
        positions: Cesium.Cartesian3.fromDegreesArrayHeights(points),
        width: 15,
    }
});
Run Code Online (Sandbox Code Playgroud)

我使用了Entity.removeAll(),但它正在从铯容器中删除整个数据(包括模型等)。我只想删除折线。

ema*_*key 3

保存返回值entities.add,这是对新创建实体的引用。

var polylineEntity = viewer.entities.add({
    //...
});
Run Code Online (Sandbox Code Playgroud)

稍后,您可以通过引用删除特定实体。

viewer.entities.remove(polylineEntity);
Run Code Online (Sandbox Code Playgroud)