-
Can someone tell me if it's possible to dynamically update the paint properties of a LineLayer? For example, if I have this layer:
And the outlineOptions object looks like this:
When my site changes color themes there's a function that inserts a new color into the line-color property of outlineOptions. Can someone please tell me if I'm missing something or approaching this the wrong way? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick reply. One thing I noticed is that if I use Dynamically changing the color of a line seems like it would be a pretty commonly-used operation. The official Maplibre website even has an example of how to do it: https://maplibre.org/maplibre-gl-js/docs/examples/color-switcher/ I must be missing something, |
Beta Was this translation helpful? Give feedback.
-
Finally figured it out. After revisiting the setPaintProperty method I'm able to change the outline color on the map using the format:
Just be sure the map instance exists first. |
Beta Was this translation helpful? Give feedback.
Finally figured it out. After revisiting the setPaintProperty method I'm able to change the outline color on the map using the format:
myMap.setPaintProperty('layerId', 'paintPropertyName', newColorValue] )
Just be sure the map instance exists first.
And no need to bind the data object to the paint property in LineLayer. Just use
paint={myPaintPropertyObject}
Thanks dabreegster for you suggestions that helped find the answer.