# Change Polyline Color depending on a parameter

**URL:** <https://community.cesium.com/t/change-polyline-color-depending-on-a-parameter/540>\
**Category:** CesiumJS\
**Created:** [June 12, 2013, 5:54pm UTC](https://community.cesium.com/t/change-polyline-color-depending-on-a-parameter/540 "2013-06-12T17:54:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arnaud\_Vandecasteele](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/arnaud_vandecasteele/32/23009_2.png) [@Arnaud\_Vandecasteele](https://community.cesium.com/u/Arnaud_Vandecasteele)\
**Post date:** [June 12, 2013, 5:54pm UTC](https://community.cesium.com/t/change-polyline-color-depending-on-a-parameter/540/1 "2013-06-12T17:54:39Z")

</div>

Hello Cesium Team,

Depending on a parameter (e.g. speed) I would like to be able to have a different color for each segment of a trajectory. In the sandbox there is an example on how to change the width of a polyline but not on how to change its color. The others example I've looked change the color of a whole polygone collection.

By looking in the code source, I tried different solutions but none of them have worked.

This is what I'm doing right now but with no success:  
[http://pastebin.com/c3QKAwiw](http://pastebin.com/c3QKAwiw)

Do you know how could I set the color of each segment?

Thanks

Arnaud

---

<div class="post-metadata">

**Author:** ![Mark\_Erikson](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/mark_erikson/32/2024_2.png) [@Mark\_Erikson](https://community.cesium.com/u/Mark_Erikson)\
**Post date:** [June 12, 2013, 7:50pm UTC](https://community.cesium.com/t/change-polyline-color-depending-on-a-parameter/540/2 "2013-06-12T19:50:46Z")

</div>

PolylineCollection.add returns a Polyline object. You should be able to either save that reference or get a reference from the collection, then update the material’s color later in your code. Something like:

myPolyline.getMaterial().uniforms.color = newColor;

---

<div class="post-metadata">

**Author:** ![Arnaud\_Vandecasteele](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/arnaud_vandecasteele/32/23009_2.png) [@Arnaud\_Vandecasteele](https://community.cesium.com/u/Arnaud_Vandecasteele)\
**Post date:** [June 13, 2013, 12:17pm UTC](https://community.cesium.com/t/change-polyline-color-depending-on-a-parameter/540/3 "2013-06-13T12:17:02Z")

</div>

Hello Mark,

```
It works perfectly.
Thanks

Arnaud
```
