如何在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,
}
});我使用了entities.removeAll(),但它删除了is中的整个数据(包括模型等)。我只想删除多段线。
发布于 2015-12-24 20:18:16
保存entities.add的返回值,这是对新创建的实体的引用。
var polylineEntity = viewer.entities.add({
//...
});稍后,您可以通过引用移除特定的实体。
viewer.entities.remove(polylineEntity);发布于 2017-09-03 18:49:30
var pathDone; //Store dataSource so later can be removed.
viewer.dataSources.remove(pathDone,true); // Removing old data.
Cesium.GeoJsonDataSource.load(data, { // Data contains geojson, linestring z.
stroke: Cesium.Color.HOTPINK,
fill: Cesium.Color.PINK.withAlpha(0.5),
strokeWidth: 2
}).then(function(geoData){
viewer.dataSources.add(geoData); //Adding new one.
pathDone=geoData;//Storing new reference.
});这对我很有效。
https://stackoverflow.com/questions/34450497
复制相似问题