Applying a new style (stroke color) to a GeoJSON polygon

Second chapter of an old question of mine (which I was able to solve): Applying a new style to a GeoJSON polygon

Now I want to dynamically change the stroke color of a geojson loaded source.

          loaded = await datasource.load(figure, {
            stroke: BORDER_COLOR.withAlpha(0.7)
            fill: A_COLOR
          });

Setting the stroke is working properly (not the stroke strokeWidth, but as I read, this can be a limitation of WebGL).

Unluckily I’m not able to change that color later. If I try something like entity.polygon.outlineColor = new Cesium.ColorMaterialProperty(NEW_COLOR); it just makes stroke color white.

Is this supported someway?

Hi @keul, thanks for the question

You can change the polygon outline color by just specifying the color, you don’t need to create a new material property

entity.polygon.outlineColor = Cesium.Color.PINK;

Quick sandcastle showing changing outline colors on click here

Hi @jjspacem thanks for the reply. outlineColor is exactly the API I tried, but is not working for me. Nor seems to work in your example: I don’t see countries borders to be PINK or any pink on the page

@keul the sandcastle I posted above changes the outline after you click a state. I thought it would better illustrate changing the outline after the primitives are created, I’m sorry if this caused confusion.


I have confirmed this working across 2 devices so I would expect it to work for you but maybe there’s something else wrong. If it’s still not working for you would you be able to provide a minimal sandcastle of the code that’s not working?

OK, in facts this is working and is quite similar to what I’m trying to obtain.
But in my page, changing the color makes them white, no matter which color I use.

I’ll try to arrange a sandcastle, but is not easy.

Thanks!