tangram-es
tangram-es copied to clipboard
Multiple labels per point feature?
I'm working on a map where many small point markers are labeled with two different labels, a primary label (left) and a subscript label (bottom-right). This is accomplished via two text styles used in the draw group, along with a points style, however, the labels are not removed when the point is removed due to collision. I need the everything to disappear whenever any one part is removed.
Is this possible?
Sorry for the delay. Unfortunately, there is no built-in way to do this right now. You get nice text handling for anchoring, collision, etc. by attaching/nesting a text block underneath your points, but it only supports a single text label at this time.
If I were trying to hack this myself, I might try something more involved like rendering the various label combinations yourself (either offline, or at run-time such as with the Canvas text API, which Tangram also uses internally), to a sprite with a transparent background, the compositing that, centered on top of the relevant points style (it could still be text nested under points, with anchor: center). I realize this is a heavy lift, but thought I'd throw it out there anyway :)
Keeping this open to log as an enhancement request.
Thanks! I think that I may have found a workaround for my particular case using Unicode characters for the subscripts, which are always numeric, and centering a single label on the point.