# Polyline removeAll Collection bug?

**URL:** <https://community.cesium.com/t/polyline-removeall-collection-bug/2069>\
**Category:** CesiumJS\
**Created:** [February 26, 2015, 7:23pm UTC](https://community.cesium.com/t/polyline-removeall-collection-bug/2069 "2015-02-26T19:23:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Rutherford](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@Matthew\_Rutherford](https://community.cesium.com/u/Matthew_Rutherford)\
**Post date:** [February 26, 2015, 7:23pm UTC](https://community.cesium.com/t/polyline-removeall-collection-bug/2069/1 "2015-02-26T19:23:35Z")

</div>

Hi Cesium team,

I have encounted some issues when working with Polyline collections. The following code will throw an error when using either kind of removeAll when removing more than one polyline at a time.

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

var scene = viewer.scene;

scene.primitives.add(new Cesium.PolylineCollection());

scene.primitives.add(new Cesium.LabelCollection());

var material3 = Cesium.Material.fromType(‘Color’);

var polylines = scene.primitives.get(0);

var poly;

var labels = scene.primitives.get(1);

var index=0;

for (index = 0; index \< 5; index++) {

var positions = [-96+index, 30+index, -98+index, 32+index];

positions = Cesium.Cartesian3.fromDegreesArray(positions);

poly=polylines.add({

positions : positions,

width : 2,

material: material3

});

poly.material.uniforms.color = Cesium.Color.AQUA;

labels.add({

position : Cesium.Cartesian3.fromDegrees(-96+index, 30+index),

text : ‘A label’+index

});

}

polylines.removeAll();

[//scene.primitives.removeAll](https://scene.primitives.removeAll)();

Changing the polylines.add material parameter to the following fixed the issue.

material: Cesium.Material.fromType(‘Color’)

So I assume that this has something to do with passing a material by reference or something. Will things stay this way? On a side note I noticed a syntax error in the PolylineCollection documentation in the first example. the ‘positions’ property is spelled ‘position’ for the first polyline.

[http://cesiumjs.org/Cesium/Build/Documentation/PolylineCollection.html?classFilter=polylinecoll](http://cesiumjs.org/Cesium/Build/Documentation/PolylineCollection.html?classFilter=polylinecoll)

Another question I had was whether there were plans to bring back the Geometry and Appearances SandCastle back to using Geometries instead of entities. It has some great examples that I used.

Thanks,

Matt

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [March 5, 2015, 6:50pm UTC](https://community.cesium.com/t/polyline-removeall-collection-bug/2069/2 "2015-03-05T18:50:32Z")

</div>

Thanks for the heads up. You are probably running into this bug: [https://github.com/AnalyticalGraphicsInc/cesium/issues/1567](https://github.com/AnalyticalGraphicsInc/cesium/issues/1567)  
The workaround is to just create a material per line. In your example, get rid of material3 and replace it with Cesium.Material.fromType(‘Color’); in your add call.
