# Style by Attribute (GeoJSON)

**URL:** <https://community.cesium.com/t/style-by-attribute-geojson/8869>\
**Category:** CesiumJS\
**Created:** [November 22, 2019, 3:51pm UTC](https://community.cesium.com/t/style-by-attribute-geojson/8869 "2019-11-22T15:51:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rory123mcinnes](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@rory123mcinnes](https://community.cesium.com/u/rory123mcinnes)\
**Post date:** [November 22, 2019, 3:51pm UTC](https://community.cesium.com/t/style-by-attribute-geojson/8869/1 "2019-11-22T15:51:12Z")

</div>

**1. A concise explanation of the problem you’re experiencing.**

Hello! I am trying to style GeoJSON polygons by SymbolID (a field with values from 0-3). I’m very new to Cesium and I’m loving how much great documentation is out there but I think I’m missing something somewhere.

**2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.**

var promise = Cesium.GeoJsonDataSource.load(‘my\_geojson\_file’);

promise.then(function (dataSource) {

viewer.dataSources.add(dataSource);

var entities = dataSource.entities.values;

var colourhash = {};

for (var i = 0; i \< entities.length; i++) {

var entity = entities[i];

var symID = entity.SymbolID;

var colour = colourhash[symID];

if (colour === 2) {

colour = Cesium.Color.FORESTGREEN({  
alpha: 1.0  
});

colourhash[symID] = colour;  
}

entity.polygon.material = colour;

entity.polygon.extrudedHeight = entity.properties.Height;}

**3. Context. Why do you need to do this? We might know a better way to accomplish your goal.**

The GeoJSON polygons represent a heatmap, I’m trying to symbolize them to a set colours that correspond to some categories. I used [this](https://sandcastle.cesium.com/index.html?src=GeoJSON%20and%20TopoJSON.html)example in the sandbox to help create my code.

**4. The Cesium version you’re using, your operating system and browser.**

Cesium = 1.63.1

Windows = 10

Geoserver = 2.14.2

Google chrom

---

<div class="post-metadata">

**Author:** ![rory123mcinnes](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@rory123mcinnes](https://community.cesium.com/u/rory123mcinnes)\
**Post date:** [December 2, 2019, 5:45pm UTC](https://community.cesium.com/t/style-by-attribute-geojson/8869/2 "2019-12-02T17:45:34Z")

</div>

See [this](https://groups.google.com/forum/#!topic/cesium-dev/5TPOuifq9yI)question for my solution.
