# Symbol Layer

A symbol layer renders map features as icons and/or text. The layer data source should supply point, line or polygon data.

<!-- Text layer -->
<flow-map-layer type="symbol" ...>
  text-field: @name;
  text-variable-anchor: ['top'];
  text-radial-offset: 1.5;
</flow-map-layer>
<!-- Icon layer -->
<flow-map-layer type="symbol" ...>
  icon-image: 'star';
  icon-allow-overlap: true;
</flow-map-layer>

# Layout Properties

▸ symbol-placement (opens new window)

Optional enum (default: point).

ValueDescription
point
The label is placed at the point where the geometry is located.
line
The label is placed along the line of the geometry. Can only be used on LineString and Polygon geometries.
line-center
The label is placed at the center of the line of the geometry. Can only be used on LineString and Polygon geometries. Note that a single feature in a vector tile may contain multiple line geometries.

Label placement relative to its geometry.

▸ symbol-spacing (opens new window)

Optional number (default: 250): minimum = 1.

Distance between two symbol anchors.

▸ symbol-avoid-edges (opens new window)

Optional boolean (default: false).

If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like Mapbox GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries.

▸ symbol-sort-key (opens new window)

number.

Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When icon-allow-overlap or text-allow-overlap is false, features with a lower sort key will have priority during placement. When icon-allow-overlap or text-allow-overlap is set to true, features with a higher sort key will overlap over features with a lower sort key.

▸ symbol-z-order (opens new window)

Optional enum (default: auto).

ValueDescription
auto
Sorts symbols by symbol-sort-key if set. Otherwise, sorts symbols by their y-position relative to the viewport if icon-allow-overlap or text-allow-overlap is set to true or icon-ignore-placement or text-ignore-placement is false.
viewport-y
Sorts symbols by their y-position relative to the viewport if icon-allow-overlap or text-allow-overlap is set to true or icon-ignore-placement or text-ignore-placement is false.
source
Sorts symbols by symbol-sort-key if set. Otherwise, no sorting is applied; symbols are rendered in the same order as the source data.

Determines whether overlapping symbols in the same layer are rendered in the order that they appear in the data source or by their y-position relative to the viewport. To control the order and prioritization of symbols otherwise, use symbol-sort-key.

▸ icon-allow-overlap (opens new window)

Optional boolean (default: false).

If true, the icon will be visible even if it collides with other previously drawn symbols.

▸ icon-ignore-placement (opens new window)

Optional boolean (default: false).

If true, other symbols can be visible even if they collide with the icon.

▸ icon-optional (opens new window)

Optional boolean (default: false).

If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not.

▸ icon-rotation-alignment (opens new window)

Optional enum (default: auto).

ValueDescription
map
When symbol-placement is set to point, aligns icons east-west. When symbol-placement is set to line or line-center, aligns icon x-axes with the line.
viewport
Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of symbol-placement.
auto
When symbol-placement is set to point, this is equivalent to viewport. When symbol-placement is set to line or line-center, this is equivalent to map.

In combination with symbol-placement, determines the rotation behavior of icons.

▸ icon-size (opens new window)

Optional number (default: 1): minimum = 0.

Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by icon-size. 1 is the original size; 3 triples the size of the image.

▸ icon-text-fit (opens new window)

Optional enum (default: none).

ValueDescription
none
The icon is displayed at its intrinsic aspect ratio.
width
The icon is scaled in the x-dimension to fit the width of the text.
height
The icon is scaled in the y-dimension to fit the height of the text.
both
The icon is scaled in both x- and y-dimensions.

Scales the icon to fit around the associated text.

▸ icon-text-fit-padding (opens new window)

Optional array (default: 0,0,0,0).

Size of the additional area added to dimensions determined by icon-text-fit, in clockwise order: top, right, bottom, left.

▸ icon-image (opens new window)

resolvedImage.

Name of image in sprite to use for drawing an image background.

▸ icon-rotate (opens new window)

Optional number (default: 0).

Rotates the icon clockwise.

▸ icon-padding (opens new window)

Optional number (default: 2): minimum = 0.

Size of the additional area around the icon bounding box used for detecting symbol collisions.

▸ icon-keep-upright (opens new window)

Optional boolean (default: false).

If true, the icon may be flipped to prevent it from being rendered upside-down.

▸ icon-offset (opens new window)

Optional array (default: 0,0).

Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of icon-size to obtain the final offset in pixels. When combined with icon-rotate the offset will be as if the rotated direction was up.

▸ icon-anchor (opens new window)

Optional enum (default: center).

ValueDescription
center
The center of the icon is placed closest to the anchor.
left
The left side of the icon is placed closest to the anchor.
right
The right side of the icon is placed closest to the anchor.
top
The top of the icon is placed closest to the anchor.
bottom
The bottom of the icon is placed closest to the anchor.
top-left
The top left corner of the icon is placed closest to the anchor.
top-right
The top right corner of the icon is placed closest to the anchor.
bottom-left
The bottom left corner of the icon is placed closest to the anchor.
bottom-right
The bottom right corner of the icon is placed closest to the anchor.

Part of the icon placed closest to the anchor.

▸ icon-pitch-alignment (opens new window)

Optional enum (default: auto).

ValueDescription
map
The icon is aligned to the plane of the map.
viewport
The icon is aligned to the plane of the viewport.
auto
Automatically matches the value of icon-rotation-alignment.

Orientation of icon when map is pitched.

▸ text-pitch-alignment (opens new window)

Optional enum (default: auto).

ValueDescription
map
The text is aligned to the plane of the map.
viewport
The text is aligned to the plane of the viewport.
auto
Automatically matches the value of text-rotation-alignment.

Orientation of text when map is pitched.

▸ text-rotation-alignment (opens new window)

Optional enum (default: auto).

ValueDescription
map
When symbol-placement is set to point, aligns text east-west. When symbol-placement is set to line or line-center, aligns text x-axes with the line.
viewport
Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of symbol-placement.
auto
When symbol-placement is set to point, this is equivalent to viewport. When symbol-placement is set to line or line-center, this is equivalent to map.

In combination with symbol-placement, determines the rotation behavior of the individual glyphs forming the text.

▸ text-field (opens new window)

Optional formatted (default: ).

Value to use for a text label. If a plain string is provided, it will be treated as a formatted with default/inherited formatting options.

▸ text-font (opens new window)

Optional array (default: Open Sans Regular,Arial Unicode MS Regular).

Font stack to use for displaying text.

▸ text-size (opens new window)

Optional number (default: 16): minimum = 0.

Font size.

▸ text-max-width (opens new window)

Optional number (default: 10): minimum = 0.

The maximum line width for text wrapping.

▸ text-line-height (opens new window)

Optional number (default: 1.2).

Text leading value for multi-line text.

▸ text-letter-spacing (opens new window)

Optional number (default: 0).

Text tracking amount.

▸ text-justify (opens new window)

Optional enum (default: center).

ValueDescription
auto
The text is aligned towards the anchor position.
left
The text is aligned to the left.
center
The text is centered.
right
The text is aligned to the right.

Text justification options.

▸ text-radial-offset (opens new window)

Optional number (default: 0).

Radial offset of text, in the direction of the symbol's anchor. Useful in combination with text-variable-anchor, which defaults to using the two-dimensional text-offset if present.

▸ text-variable-anchor (opens new window)

array.

ValueDescription
center
The center of the text is placed closest to the anchor.
left
The left side of the text is placed closest to the anchor.
right
The right side of the text is placed closest to the anchor.
top
The top of the text is placed closest to the anchor.
bottom
The bottom of the text is placed closest to the anchor.
top-left
The top left corner of the text is placed closest to the anchor.
top-right
The top right corner of the text is placed closest to the anchor.
bottom-left
The bottom left corner of the text is placed closest to the anchor.
bottom-right
The bottom right corner of the text is placed closest to the anchor.

To increase the chance of placing high-priority labels on the map, you can provide an array of text-anchor locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use text-justify: auto to choose justification based on anchor position. To apply an offset, use the text-radial-offset or the two-dimensional text-offset.

▸ text-anchor (opens new window)

Optional enum (default: center).

ValueDescription
center
The center of the text is placed closest to the anchor.
left
The left side of the text is placed closest to the anchor.
right
The right side of the text is placed closest to the anchor.
top
The top of the text is placed closest to the anchor.
bottom
The bottom of the text is placed closest to the anchor.
top-left
The top left corner of the text is placed closest to the anchor.
top-right
The top right corner of the text is placed closest to the anchor.
bottom-left
The bottom left corner of the text is placed closest to the anchor.
bottom-right
The bottom right corner of the text is placed closest to the anchor.

Part of the text placed closest to the anchor.

▸ text-max-angle (opens new window)

Optional number (default: 45).

Maximum angle change between adjacent characters.

▸ text-writing-mode (opens new window)

array.

ValueDescription
horizontal
If a text's language supports horizontal writing mode, symbols with point placement would be laid out horizontally.
vertical
If a text's language supports vertical writing mode, symbols with point placement would be laid out vertically.

The property allows control over a symbol's orientation. Note that the property values act as a hint, so that a symbol whose language doesn’t support the provided orientation will be laid out in its natural orientation. Example: English point symbol will be rendered horizontally even if array value contains single 'vertical' enum value. The order of elements in an array define priority order for the placement of an orientation variant.

▸ text-rotate (opens new window)

Optional number (default: 0).

Rotates the text clockwise.

▸ text-padding (opens new window)

Optional number (default: 2): minimum = 0.

Size of the additional area around the text bounding box used for detecting symbol collisions.

▸ text-keep-upright (opens new window)

Optional boolean (default: true).

If true, the text may be flipped vertically to prevent it from being rendered upside-down.

▸ text-transform (opens new window)

Optional enum (default: none).

ValueDescription
none
The text is not altered.
uppercase
Forces all letters to be displayed in uppercase.
lowercase
Forces all letters to be displayed in lowercase.

Specifies how to capitalize text, similar to the CSS text-transform property.

▸ text-offset (opens new window)

Optional array (default: 0,0).

Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with text-variable-anchor, input values will be taken as absolute values. Offsets along the x- and y-axis will be applied automatically based on the anchor position.

▸ text-allow-overlap (opens new window)

Optional boolean (default: false).

If true, the text will be visible even if it collides with other previously drawn symbols.

▸ text-ignore-placement (opens new window)

Optional boolean (default: false).

If true, other symbols can be visible even if they collide with the text.

▸ text-optional (opens new window)

Optional boolean (default: false).

If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not.

▸ visibility (opens new window)

Optional boolean (default: true).

Whether this layer is displayed.

# Paint Properties

▸ icon-opacity (opens new window)

Optional number (default: 1): between 0 and 1 inclusive.

The opacity at which the icon will be drawn.

▸ icon-color (opens new window)

Optional color (default: #000000).

The color of the icon. This can only be used with sdf icons.

▸ icon-halo-color (opens new window)

Optional color (default: rgba(0, 0, 0, 0)).

The color of the icon's halo. Icon halos can only be used with SDF icons.

▸ icon-halo-width (opens new window)

Optional number (default: 0): minimum = 0.

Distance of halo to the icon outline.

▸ icon-halo-blur (opens new window)

Optional number (default: 0): minimum = 0.

Fade out the halo towards the outside.

▸ icon-translate (opens new window)

Optional array (default: 0,0).

Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.

▸ icon-translate-anchor (opens new window)

Optional enum (default: map).

ValueDescription
map
Icons are translated relative to the map.
viewport
Icons are translated relative to the viewport.

Controls the frame of reference for icon-translate.

▸ text-opacity (opens new window)

Optional number (default: 1): between 0 and 1 inclusive.

The opacity at which the text will be drawn.

▸ text-color (opens new window)

Optional color (default: #000000).

The color with which the text will be drawn.

▸ text-halo-color (opens new window)

Optional color (default: rgba(0, 0, 0, 0)).

The color of the text's halo, which helps it stand out from backgrounds.

▸ text-halo-width (opens new window)

Optional number (default: 0): minimum = 0.

Distance of halo to the font outline. Max text halo width is 1/4 of the font-size.

▸ text-halo-blur (opens new window)

Optional number (default: 0): minimum = 0.

The halo's fadeout distance towards the outside.

▸ text-translate (opens new window)

Optional array (default: 0,0).

Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.

▸ text-translate-anchor (opens new window)

Optional enum (default: map).

ValueDescription
map
The text is translated relative to the map.
viewport
The text is translated relative to the viewport.

Controls the frame of reference for text-translate.