Dash-leaflet creating callback to allow user adjust map color class breaks

I think the answer to this is broadly along these lines:

The style function you’ve written will probably accept an additional parameter context. (onEachFeature and pointToLayer definitely do, but I’ve not tried it with style)

The hideout property of your GeoJSON layer can be accessed (from within your JavaScript function) as context.hideout

The hideout property can be updated in a callback (and can be a Python dictionary~JavaScript object)

So if you store your color scheme in hideout, you can both update it from callbacks and access it in your style function. A change to hideout should trigger re-rendering. (In a clientside callback you may need to clone the hideout object - see this thread (Dash-leaflet - Problem updating hideout in a clientside callback))

2 Likes