I'm using the deck.gl GeoJsonLayer to display regions on a map. through an event, I was able to make these regions selectable. what I am struggling with, is to change the color of a feature in the feature selection after clicking on it.
this is the render layer function (adapted from here)
_renderLayers(props) {
const { geofeats } = props;
return [
new GeoJsonLayer({
id: 'geojson',
data: geofeats,
opacity: 0.8,
stroked: true,
filled: true,
extruded: true,
wireframe: true,
getElevation: f => 10000,
getFillColor: f =>
{
if(f.properties.selected)
{
return [200, 200, 100];
} else return [200, 100, 150];
},
getLineColor: [255, 255, 255],
pickable: true,
onHover: this._onHover,
onClick: this._onClick
})
];
}
the problem is, when I update the selection state of a feature in the feature collection via setState(), the rendering is not updated even though the state change is represented in the data..
this is how I relay the 'geofeats' object:
render() {
const {features} = this.state;
const {mapStyle = 'mapbox://styles/mapbox/light-v9'} = this.props;
return (
<DeckGL
layers={this._renderLayers({geofeats: features})}
effects={this._effects}
initialViewState={INITIAL_VIEW_STATE}
controller={true}
>
<StaticMap
reuseMaps
mapStyle={mapStyle}
preventStyleDiffing={true}
mapboxApiAccessToken={MAPBOX_TOKEN}
/>
{this._renderTooltip}
</DeckGL>
);
}
I tried it via setState instead of via props - but the result is the same. the feature collection is handed over to the GeoJsonLayer but never updated.
could someone tell me, what I'm doing wrong?
Update: gist example with error reproduction: https://gist.github.com/jaronimoe/efdbb58b3f52c2aac63362a921802cfe