[cesium-dev] How can I remove polyline?

Since you are adding it to viewer.entities, you need to remove it from there as well. Either viewer.entities.remove(redLine) or viewer.entities.removeAll() will work. Try pasting this code into Sandcastle:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var redLine = viewer.entities.add({

name : ‘Red line on the surface’,

polyline : {

positions : Cesium.Cartesian3.fromDegreesArray([-75, 35,

-125, 35]),

width : 5,

material : Cesium.Color.RED

}

});

Sandcastle.addToolbarButton(‘Remove’, function() {

viewer.entities.remove(redLine);

});

Sandcastle.addToolbarButton(‘Remove all’, function() {

viewer.entities.removeAll();

});

If you have an example that you think should work but doesn’t, please let us know.