The label block
The label block defines how feature labels are rendered.
These are the properties available to define label rendering. Anchors can be lines or points, polygons are not supported.
Type | Applies to | Description | |
---|---|---|---|
| string | auto | Interpolator | Points and lines | Optional. The label color |
| string | Points and lines | Optional. The font family to use |
| number | Interpolator | Points and lines | Optional. The font size in pixels |
| normal | italic | oblique | Points and lines | Optional. The font style |
| number | Points and lines | Optional. The font weight |
| string | Interpolator | Points and lines | Optional. The label halo color |
| string | Interpolator | Points and lines | Optional. The label halo color width |
| number | Points and lines | Optional. Horizontal spacing behaviour between text characters |
| number | Points and lines | Optional. Sets the height of a line box |
| number | Interpolator | Points and lines | Optional. Defines the max number of characters before a line break |
| number | Points and lines | Optional. The maximum zoom level at which the label will be shown |
| number | Points and lines | Optional. The minimum zoom level at which the label will be shown |
| [number, number] | number | Points and lines | Optional. In the case of points, this value must be an array of two numeric offsets that will be applied on the positive X and Y axis defined by the label placement (i.e. an offset of [3,4] with a label placement of NE moves the label 3pixels to the right and 4 pixels above of the anchor point. An offset of [3,4] with a label placement of SW moves the label 3pixels to the left and 4 pixels below of the anchor point). In case of lines, this value is a single number that moves the label following the label position (i.e. an offset of 3 with a label position of Above will move the label 3 pixels above the line following the line normal. An offset of 3 with a label position of Below will mode the label 3 pixels under the line following the line normal) |
| number | Points and lines | Optional. Adds invisible padding around the label that's used to compute label collisions |
| TextPlacements[] | auto | LineLabelPlacement | Points and Lines | Optional. If defined on a points dataset, an array of label placements to test when placing the label. If all the placements collide with already existing labels, the label is not shown. If defined on a lines dataset, the label placement on a line |
| boolean | Polygons | Optional. Renders labels along lines instead of using the centroids |
| number | Lines | Optional. The distance in pixels between label repetitions on a line |
| capitalize | uppercase | lowercase | Points and lines | Optional. Specifies how to capitalize the label |
| boolean | Points, Lines and Polygons | Optional. A flag to tell if labels should be clickable |
| boolean | Points, Lines and Polygons | Optional. A flag to tell if labels should be hoverable |
See default values of these attributes on each label type.
If using a categorical
or numeric
visualization, all the previous properties must be arrays. If there's a single value in the array, that value is used in all categories. If there are as many values as categories
, the corresponding value will be used for each category. You can see an example of a categorical
viz here.
Default values
Name | Points | Lines | Centroids |
---|---|---|---|
| "#333333" | "#333333" | "#333333" |
| "Atlas Grotesk LC" | "Atlas Grotesk LC" | "Atlas Grotesk LC" |
| 13 | 13 | 13 |
| "Normal" | "Normal" | "Normal" |
| 500 | 400 | 500 |
| "#fbfcfb" | "#fbfcfb" | "#fbfcfb" |
| 1 | 1 | 1 |
| “auto” | “auto” | “auto” |
| 0 | 0 | 0 |
| 1.2 | 1.2 | 1.2 |
| 10 | - | 10 |
| - | 30 | - |
| 23 | 23 | 23 |
| 23 | 23 | 23 |
| [8, 8] | 0 | - |
| 2 | 1 | 0 |
| “auto” | “Above” | “Center” |
| - | 250 | - |
| "none" | "none" | "none" |
Last updated