Clarify the format that is required for getColor for all layers.
I'm new to map work and am used to colors being in HTML/CSS format (hex color code #000000 or rgba(255, 255, 255, 1)). I couldn't figure out why the PathLayer paths weren't showing up, as my colors were in hex code format. Maybe it's obvious to others but an RGB array is not something you see often.
Also, I'm not sure if this is a bug or not, but trying out an RGBA array ([255, 255, 255, 1]) isn't working for my PathLayer whereas RGB does ([255, 255, 255]). For example, getColor: [175, 240, 91, 1] doesn't work but getColor: [175, 240, 91] does.
Thanks for reporting this.
Color is an array of 4 elements, each in the range of 0 to 255, with a being optional. When a not specified it is set to 255.
When you use [255, 255, 255, 1], you are using very small value for a (alpha channel) which makes is completely transparent, hence not visible. Try setting it to 255.
One thing we can do is clarify how a effects the transparency when specified.
From the current documentation:
The rgba color of each object, in r, g, b, [a]. Each component is in the 0-255 range.
First of all, thank you for the quick replies!
@1chandu Thanks for the great explanation. Cleared up the confusion about a as well 馃憤
It's unfortunate though since rgba() in CSS uses a value of 0 - 1 for alpha. (I was converting it from an object, like tinycolor2's { r, g, b, a }.) But I'm guessing the rgba tuple(?) format is common outside CSS and JS, and would break a lot of implementations if it was changed.
@Pessimistress
From the current documentation:
The rgba color of each object, in r, g, b, [a]. Each component is in the 0-255 range.
This is not clear to me. I guess "in" implies "in array"? 馃 And "component" means "value"? I also didn't interpret this literally for a as I assumed it was like CSS's rgba 馃し鈥嶁檧 That's my bad, of course, just trying to clarify why I didn't understand the current documentation.
Would it be possible to expand on what's in the documentation currently with what @1chandu wrote? Maybe something like "The rgba color of each object, like [ r, g, b, [a] ]. The color is an array with each value in the range of 0-255. a is 255 by default."
To use a value between 0-1, you can simply multiply your range by 255.
I.e. 50% black would be [0, 0, 0, 0.5 * 255].
@1chandu I am updating the layer docs so wanted to confirm before changing every file.
Updating the below line with the following line
The rgba color at the source, in `r, g, b, [a]`. Each component is in the 0-255 range.
The rgba color at the source, like `[r, g, b, [a]]`. The `r, g, b, a` is in 0-255 range and `a` is 255 by default.