Mapbox spec: symbol
import { SymbolLayer } from '@rnmapbox/maps';
SymbolLayer
SymbolLayer is a style layer that renders icon and text labels at points or along lines on the map.
string
required A string that uniquely identifies the source in the style to which it is added.
boolean
The id refers to en existing layer in the style. Does not create a new layer.
string
The source from which to obtain the data to style. If the source has not yet been added to the current style, the behavior is undefined. Inferred from parent source only if the layer is a direct child to it.
defaults to: Mapbox.StyleSource.DefaultSourceID
string
Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
string
Inserts a layer above aboveLayerID.
string
Inserts a layer below belowLayerID
number
Inserts a layer at a specified index
FilterExpression
Filter only the features in the source layer that satisfy a condition that you define
number
The minimum zoom level at which the layer gets parsed and appears.
number
The maximum zoom level at which the layer gets parsed and appears.
'bottom' | 'middle' | 'top'
The slot this layer is assigned to. If specified, and a slot with that name exists, it will be placed at that position in the layer order.
v11 only
SymbolLayerStyleProps
required Customizable style attributes
JSX.Element | JSX.Element[]
@deprecated passed children used to create an image with id of symbol in style and also set the iconImageName property accordingly. This is now deprecated, use Image component instead.
- symbolPlacement
- symbolSpacing
- symbolAvoidEdges
- symbolSortKey
- symbolZOrder
- iconAllowOverlap
- iconIgnorePlacement
- iconOptional
- iconRotationAlignment
- iconSize
- iconTextFit
- iconTextFitPadding
- iconImage
- iconRotate
- iconPadding
- iconKeepUpright
- iconOffset
- iconAnchor
- iconPitchAlignment
- textPitchAlignment
- textRotationAlignment
- textField
- textFont
- textSize
- textMaxWidth
- textLineHeight
- textLetterSpacing
- textJustify
- textRadialOffset
- textVariableAnchor
- textAnchor
- textMaxAngle
- textWritingMode
- textRotate
- textPadding
- textKeepUpright
- textTransform
- textOffset
- textAllowOverlap
- textIgnorePlacement
- textOptional
- visibility
- iconOpacity
- iconColor
- iconHaloColor
- iconHaloWidth
- iconHaloBlur
- iconTranslate
- iconTranslateAnchor
- textOpacity
- textColor
- textHaloColor
- textHaloWidth
- textHaloBlur
- textTranslate
- textTranslateAnchor
Name: symbolPlacement
Mapbox spec: symbol-placement
Label placement relative to its geometry.
enum
point
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.
Parameters: zoom
Name: symbolSpacing
Mapbox spec: symbol-spacing
Distance between two symbol anchors.
number
250
pixels
1
Parameters: zoom
Name: symbolAvoidEdges
Mapbox spec: symbol-avoid-edges
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.
boolean
false
Parameters: zoom
Name: symbolSortKey
Mapbox spec: symbol-sort-key
Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When iconAllowOverlap
or textAllowOverlap
is false
, features with a lower sort key will have priority during placement. When iconAllowOverlap
or textAllowOverlap
is set to true
, features with a higher sort key will overlap over features with a lower sort key.
number
Parameters: zoom, feature
Name: symbolZOrder
Mapbox spec: symbol-z-order
Determines whether overlapping symbols in the same layer are rendered in the order that they appear in the data source or by their yPosition relative to the viewport. To control the order and prioritization of symbols otherwise, use symbolSortKey
.
enum
auto
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.
Parameters: zoom
Name: iconAllowOverlap
Mapbox spec: icon-allow-overlap
If true, the icon will be visible even if it collides with other previously drawn symbols.
boolean
false
iconImage
Parameters: zoom
Name: iconIgnorePlacement
Mapbox spec: icon-ignore-placement
If true, other symbols can be visible even if they collide with the icon.
boolean
false
iconImage
Parameters: zoom
Name: iconOptional
Mapbox spec: icon-optional
If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not.
boolean
false
iconImage, textField
Parameters: zoom
Name: iconRotationAlignment
Mapbox spec: icon-rotation-alignment
In combination with symbolPlacement
, determines the rotation behavior of icons.
enum
auto
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
.
iconImage
Parameters: zoom
Name: iconSize
Mapbox spec: icon-size
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 iconSize
. 1 is the original size; 3 triples the size of the image.
number
1
factor of the original icon size
0
iconImage
Parameters: zoom, feature
Name: iconTextFit
Mapbox spec: icon-text-fit
Scales the icon to fit around the associated text.
enum
none
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.
iconImage, textField
Parameters: zoom, feature
Name: iconTextFitPadding
Mapbox spec: icon-text-fit-padding
Size of the additional area added to dimensions determined by iconTextFit
, in clockwise order: top, right, bottom, left.
array<number>
[0,0,0,0]
pixels
iconImage, textField
Parameters: zoom, feature
Name: iconImage
Mapbox spec: icon-image
Name of image in sprite to use for drawing an image background.
resolvedImage
Parameters: zoom, feature
Name: iconRotate
Mapbox spec: icon-rotate
Rotates the icon clockwise.
number
0
degrees
iconImage
Parameters: zoom, feature
Name: iconPadding
Mapbox spec: icon-padding
Size of the additional area around the icon bounding box used for detecting symbol collisions.
number
2
pixels
0
iconImage
Parameters: zoom
Name: iconKeepUpright
Mapbox spec: icon-keep-upright
If true, the icon may be flipped to prevent it from being rendered upsideDown.
boolean
false
iconImage
Parameters: zoom
Name: iconOffset
Mapbox spec: icon-offset
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 iconSize
to obtain the final offset in pixels. When combined with iconRotate
the offset will be as if the rotated direction was up.
array<number>
[0,0]
iconImage
Parameters: zoom, feature
Name: iconAnchor
Mapbox spec: icon-anchor
Part of the icon placed closest to the anchor.
enum
center
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.
iconImage
Parameters: zoom, feature
Name: iconPitchAlignment
Mapbox spec: icon-pitch-alignment
Orientation of icon when map is pitched.
enum
auto
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
.
iconImage
Parameters: zoom
Name: textPitchAlignment
Mapbox spec: text-pitch-alignment
Orientation of text when map is pitched.
enum
auto
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
.
textField
Parameters: zoom
Name: textRotationAlignment
Mapbox spec: text-rotation-alignment
In combination with symbolPlacement
, determines the rotation behavior of the individual glyphs forming the text.
enum
auto
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
.
textField
Parameters: zoom
Name: textField
Mapbox spec: text-field
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. SDF images are not supported in formatted text and will be ignored.
formatted
``
Parameters: zoom, feature
Name: textFont
Mapbox spec: text-font
Font stack to use for displaying text.
array<string>
[Open Sans Regular,Arial Unicode MS Regular]
textField
camera
Parameters: zoom, feature
Name: textSize
Mapbox spec: text-size
Font size.
number
16
pixels
0
textField
Parameters: zoom, feature
Name: textMaxWidth
Mapbox spec: text-max-width
The maximum line width for text wrapping.
number
10
ems
0
textField
camera
Parameters: zoom, feature
Name: textLineHeight
Mapbox spec: text-line-height
Text leading value for multiLine text.
number
1.2
ems
textField
Parameters: zoom, feature
Name: textLetterSpacing
Mapbox spec: text-letter-spacing
Text tracking amount.
number
0
ems
textField
camera
Parameters: zoom, feature
Name: textJustify
Mapbox spec: text-justify
Text justification options.
enum
center
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.
textField
camera
Parameters: zoom, feature
Name: textRadialOffset
Mapbox spec: text-radial-offset
Radial offset of text, in the direction of the symbol's anchor. Useful in combination with textVariableAnchor
, which defaults to using the twoDimensional textOffset
if present.
number
0
ems
textField
Parameters: zoom, feature
Name: textVariableAnchor
Mapbox spec: text-variable-anchor
To increase the chance of placing highPriority labels on the map, you can provide an array of textAnchor
locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use textJustify: auto
to choose justification based on anchor position. To apply an offset, use the textRadialOffset
or the twoDimensional textOffset
.
array<enum>
textField
Parameters: zoom
Name: textAnchor
Mapbox spec: text-anchor
Part of the text placed closest to the anchor.
enum
center
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.
textField
textVariableAnchor
camera
Parameters: zoom, feature
Name: textMaxAngle
Mapbox spec: text-max-angle
Maximum angle change between adjacent characters.
number
45
degrees
textField
Parameters: zoom
Name: textWritingMode
Mapbox spec: text-writing-mode
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. For symbol with point placement, the order of elements in an array define priority order for the placement of an orientation variant. For symbol with line placement, the default text writing mode is either ['horizontal', 'vertical'] or ['vertical', 'horizontal'], the order doesn't affect the placement.
array<enum>
textField
Parameters: zoom
Name: textRotate
Mapbox spec: text-rotate
Rotates the text clockwise.
number
0
degrees
textField
Parameters: zoom, feature
Name: textPadding
Mapbox spec: text-padding
Size of the additional area around the text bounding box used for detecting symbol collisions.
number
2
pixels
0
textField
Parameters: zoom
Name: textKeepUpright
Mapbox spec: text-keep-upright
If true, the text may be flipped vertically to prevent it from being rendered upsideDown.
boolean
true
textField
Parameters: zoom
Name: textTransform
Mapbox spec: text-transform
Specifies how to capitalize text, similar to the CSS textTransform
property.
enum
none
none - The text is not altered.
uppercase - Forces all letters to be displayed in uppercase.
lowercase - Forces all letters to be displayed in lowercase.
textField
Parameters: zoom, feature
Name: textOffset
Mapbox spec: text-offset
Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with textVariableAnchor, input values will be taken as absolute values. Offsets along the x and yAxis will be applied automatically based on the anchor position.
array<number>
[0,0]
ems
textField
textRadialOffset
Parameters: zoom, feature
Name: textAllowOverlap
Mapbox spec: text-allow-overlap
If true, the text will be visible even if it collides with other previously drawn symbols.
boolean
false
textField
Parameters: zoom
Name: textIgnorePlacement
Mapbox spec: text-ignore-placement
If true, other symbols can be visible even if they collide with the text.
boolean
false
textField
Parameters: zoom
Name: textOptional
Mapbox spec: text-optional
If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not.
boolean
false
textField, iconImage
Parameters: zoom
Name: visibility
Mapbox spec: visibility
Whether this layer is displayed.
enum
visible
visible - The layer is shown.
none - The layer is not shown.
Parameters: ``
Name: iconOpacity
Mapbox spec: icon-opacity
The opacity at which the icon will be drawn.
number
1
0
1
iconImage
Parameters: zoom, feature, feature-state, measure-light
Name: iconOpacityTransition
The transition affecting any changes to this layer’s iconOpacity property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: iconColor
Mapbox spec: icon-color
The color of the icon. This can only be used with SDF icons.
color
#000000
iconImage
Parameters: zoom, feature, feature-state, measure-light
Name: iconColorTransition
The transition affecting any changes to this layer’s iconColor property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: iconHaloColor
Mapbox spec: icon-halo-color
The color of the icon's halo. Icon halos can only be used with SDF icons.
color
rgba(0, 0, 0, 0)
iconImage
Parameters: zoom, feature, feature-state, measure-light
Name: iconHaloColorTransition
The transition affecting any changes to this layer’s iconHaloColor property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: iconHaloWidth
Mapbox spec: icon-halo-width
Distance of halo to the icon outline.
number
0
pixels
0
iconImage
Parameters: zoom, feature, feature-state, measure-light
Name: iconHaloWidthTransition
The transition affecting any changes to this layer’s iconHaloWidth property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: iconHaloBlur
Mapbox spec: icon-halo-blur
Fade out the halo towards the outside.
number
0
pixels
0
iconImage
Parameters: zoom, feature, feature-state, measure-light
Name: iconHaloBlurTransition
The transition affecting any changes to this layer’s iconHaloBlur property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: iconTranslate
Mapbox spec: icon-translate
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.
array<number>
[0,0]
pixels
iconImage
Parameters: zoom
Name: iconTranslateTransition
The transition affecting any changes to this layer’s iconTranslate property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: iconTranslateAnchor
Mapbox spec: icon-translate-anchor
Controls the frame of reference for iconTranslate
.
enum
map
map - Icons are translated relative to the map.
viewport - Icons are translated relative to the viewport.
iconImage, iconTranslate
Parameters: zoom
Name: textOpacity
Mapbox spec: text-opacity
The opacity at which the text will be drawn.
number
1
0
1
textField
Parameters: zoom, feature, feature-state, measure-light
Name: textOpacityTransition
The transition affecting any changes to this layer’s textOpacity property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: textColor
Mapbox spec: text-color
The color with which the text will be drawn.
color
#000000
textField
Parameters: zoom, feature, feature-state, measure-light
Name: textColorTransition
The transition affecting any changes to this layer’s textColor property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: textHaloColor
Mapbox spec: text-halo-color
The color of the text's halo, which helps it stand out from backgrounds.
color
rgba(0, 0, 0, 0)
textField
Parameters: zoom, feature, feature-state, measure-light
Name: textHaloColorTransition
The transition affecting any changes to this layer’s textHaloColor property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: textHaloWidth
Mapbox spec: text-halo-width
Distance of halo to the font outline. Max text halo width is 1/4 of the fontSize.
number
0
pixels
0
textField
Parameters: zoom, feature, feature-state, measure-light
Name: textHaloWidthTransition
The transition affecting any changes to this layer’s textHaloWidth property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: textHaloBlur
Mapbox spec: text-halo-blur
The halo's fadeout distance towards the outside.
number
0
pixels
0
textField
Parameters: zoom, feature, feature-state, measure-light
Name: textHaloBlurTransition
The transition affecting any changes to this layer’s textHaloBlur property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: textTranslate
Mapbox spec: text-translate
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.
array<number>
[0,0]
pixels
textField
Parameters: zoom
Name: textTranslateTransition
The transition affecting any changes to this layer’s textTranslate property.
{ duration, delay }
milliseconds
{duration: 300, delay: 0}
Name: textTranslateAnchor
Mapbox spec: text-translate-anchor
Controls the frame of reference for textTranslate
.
enum
map
map - The text is translated relative to the map.
viewport - The text is translated relative to the viewport.
textField, textTranslate
Parameters: zoom