# Set Ellipsoid color based on hex code from database

**URL:** <https://community.cesium.com/t/set-ellipsoid-color-based-on-hex-code-from-database/9792>\
**Category:** CesiumJS\
**Created:** [June 4, 2020, 6:06pm UTC](https://community.cesium.com/t/set-ellipsoid-color-based-on-hex-code-from-database/9792 "2020-06-04T18:06:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kulvinderjatt](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kulvinderjatt/32/2895_2.png) [@kulvinderjatt](https://community.cesium.com/u/kulvinderjatt)\
**Post date:** [June 4, 2020, 6:06pm UTC](https://community.cesium.com/t/set-ellipsoid-color-based-on-hex-code-from-database/9792/1 "2020-06-04T18:06:37Z")

</div>

Hi Guys,

How can we set Ellipsoid color from the Hexcode stored in the Database ?

Thanks,  
Kulvinder Singh

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [June 8, 2020, 4:25pm UTC](https://community.cesium.com/t/set-ellipsoid-color-based-on-hex-code-from-database/9792/2 "2020-06-08T16:25:04Z")

</div>

You can change the base color of the globe like this: [https://cesium.com/docs/cesiumjs-ref-doc/Globe.html?classFilter=Globe#baseColor](https://cesium.com/docs/cesiumjs-ref-doc/Globe.html?classFilter=Globe#baseColor)

This is the color that appears when no satellite imagery is present. To set a color from a hex code use Color.fromCssColorString: [https://cesium.com/docs/cesiumjs-ref-doc/Color.html#.fromCssColorString](https://cesium.com/docs/cesiumjs-ref-doc/Color.html#.fromCssColorString)

---

<div class="post-metadata">

**Author:** ![kulvinderjatt](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kulvinderjatt/32/2895_2.png) [@kulvinderjatt](https://community.cesium.com/u/kulvinderjatt)\
**Post date:** [June 8, 2020, 4:47pm UTC](https://community.cesium.com/t/set-ellipsoid-color-based-on-hex-code-from-database/9792/3 "2020-06-08T16:47:07Z")

</div>

Thanks Omar, I will try to use this in my App.

One more thing: Is there a way in Cesium to apply Legends (Custom legends)?

Thanks,  
Kulvinder Singh

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [June 8, 2020, 4:58pm UTC](https://community.cesium.com/t/set-ellipsoid-color-based-on-hex-code-from-database/9792/4 "2020-06-08T16:58:58Z")

</div>

If you’re using Cesium Stories a legend is automatically generated for you: [https://cesium.com/docs/tutorials/stories-styling/](https://cesium.com/docs/tutorials/stories-styling/).

Otherwise you can do the same thing in your app by creating an HTML element on top of the canvas with the info you need.

---

<div class="post-metadata">

**Author:** ![kulvinderjatt](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kulvinderjatt/32/2895_2.png) [@kulvinderjatt](https://community.cesium.com/u/kulvinderjatt)\
**Post date:** [June 23, 2020, 9:22pm UTC](https://community.cesium.com/t/set-ellipsoid-color-based-on-hex-code-from-database/9792/5 "2020-06-23T21:22:41Z")

</div>

Thanks Omar, yes I did the same.

I just need to fix the colour of poly line based on the hex code value from database. Can you guide me through using which approach I can achieve this ? If any default functionality is available in Cesium?

Also can you please take a look at my other thread to control the Cesium rotation please?

Much thanks  
Kulvinder Singh

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [July 10, 2020, 7:34pm UTC](https://community.cesium.com/t/set-ellipsoid-color-based-on-hex-code-from-database/9792/6 "2020-07-10T19:34:32Z")

</div>

The examples I linked to above should do what you need: [https://cesium.com/docs/cesiumjs-ref-doc/Color.html#.fromCssColorString](https://cesium.com/docs/cesiumjs-ref-doc/Color.html#.fromCssColorString)

```auto
var cesiumBlue = Cesium.Color.fromCssColorString('#67ADDF');

```

This is a hex value for a blue color. Assuming you already have a way to retrieve this from the database, you can pass it to this CesiumJS function.

---

<div class="post-metadata">

**Author:** ![kulvinderjatt](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kulvinderjatt/32/2895_2.png) [@kulvinderjatt](https://community.cesium.com/u/kulvinderjatt)\
**Post date:** [July 10, 2020, 9:49pm UTC](https://community.cesium.com/t/set-ellipsoid-color-based-on-hex-code-from-database/9792/7 "2020-07-10T21:49:36Z")

</div>

Hi Omar,

I appreciate.

I was able to fix this few days ago.  
Much thanks for responding.  
Kulvinder Singh
