I want to set some features to use fill-color by expression, and some features use fill-pattern
the fill layer, when I use expressions to determine the style of the face, fill-color, fill-pattern will be abnormal, like this:
map.setPaintProperty("layerId","fill-pattern",
["case",["==",1,["get","num"]],"imageId", ["literal",null] ]
);
map.setPaintProperty("layerId","fill-color",
["case",["==",2,["get","num"]], "red" , "black" ]
)
browser will throw errors: Expected string but found null instead;
I solved it! If fill-pattern uses an expression, when the value of the expression is null, I create my own canvas to draw a solid-color picture instead.
Glad you figured out a solution @cdhuangyong
So I'm having the same issue -- I see the documentation says that fill-pattern will remove fill-color but I wish we could either set fill-pattern to null, and have the color come through, or set both (e.g. a transparent pattern on top of a fill)
Also @cdhuangyong I'd love to know what exactly you did!
Most helpful comment
So I'm having the same issue -- I see the documentation says that
fill-patternwill removefill-colorbut I wish we could either setfill-patternto null, and have the color come through, or set both (e.g. a transparent pattern on top of a fill)Also @cdhuangyong I'd love to know what exactly you did!