Style by Attribute (GeoJSON)

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 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

See this question for my solution.