Label Background Color

@CesiumTeam: Many thanks for this great product.

We’re using LabelCollection.add(…)
We can set font (property name font) and text color (property name fillColor)

But we are unable to find a property for setting background color of the label (color of the “small” rectangular region on which text is positioned)

Can you suggest a way to do that?

Thank you in advance.

Bulent Ozhorasan

We don’t have support for a background color at this time. It might be possible to add support but I would have to look at the code. You can specify an outline color, which may fit your needs (assuming you weren’t already aware of that options).

The problem with drawing a background color behind a label is that each letter in the label is actually a separate texture (and in fact duplicate letters share a single texure), and they aren’t all the same size. For example, here’s what it looks like when each letter is drawn with a red background:


This shows the actual dimensions of each letter.

One possibility to get a rectangular background behind the entire label would be to measure the overall width and height, and draw an appropriately sized billboard at the same position, behind the label. “Behind” from the camera’s perspective can be done with the z coordinate of the billboard’s eyeOffset. The Label/LabelCollection code calculates the total width/height as part of its layout, but we don’t currently expose any of that information.