Interface

LabelOptions

LabelOptions

Properties:
Name Type Attributes Default Description
clickable boolean <optional>
true Sets whether the label is clickable or not.
maxLength number <optional>
Maximum numbers of charectors to display. If exceeded the label will be truncated and "..." will be added to the end.
pixelOffset Size <optional>
For offsetting the label horizontal and/or vertical. A negative width will offset the label to the left and a negative height will offset the label upward. Can be specified as a object literal `{width: number, height: number}`.
style Object <optional>
For styling the label.
align string <optional>
Sets the horizontal alignment for the label. The align property is specified in one of the following ways: left, right or center.
color string <optional>
Sets the text color for the label. The color property is specified a css color value. See https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
fontFamily string <optional>
Sets the font for the label. See https://developer.mozilla.org/en-US/docs/Web/CSS/font-Family
fontSize string <optional>
Sets the font size for the label in pixels.
fontWeight number | string <optional>
Sets the font weight of the label. See https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight *fontWeight is not supported by MapBox.
strokeStyle string <optional>
Sets the stroke/outline color for the text. The strokeStyle property is specified a css color value. See https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
strokeWeight number <optional>
Sets the weight of the stroke for the text in pixels.
shadowBlur number <optional>
Sets the amount of blur applied to the text shadow. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowBlur
shadowColor string <optional>
Sets the text shadow color for the label. The color property is specified a css color value. See https://developer.mozilla.org/en-US/docs/Web/CSS/color_value

Example

//Default values LabelOptions.style:
style: {
    align: 'center',
    color: '#fff',
    fontFamily: 'Arial, Helvetica, sans-serif',
    fontSize: '12px',
    fontWeight: 500,
    strokeStyle: '#444',
    strokeWeight: 1,
    shadowBlur: 1,
    shadowColor: '#000'
}