SymbolLayer

@Composable
fun SymbolLayer(id: String, source: Source, sourceLayer: String = "", minZoom: Float = 0.0f, maxZoom: Float = 24.0f, filter: Expression<BooleanValue> = nil(), visible: Boolean = true, sortKey: Expression<FloatValue> = nil(), placement: Expression<SymbolPlacement> = const(SymbolPlacement.Point), spacing: Expression<DpValue> = const(250.dp), avoidEdges: Expression<BooleanValue> = const(false), zOrder: Expression<SymbolZOrder> = const(SymbolZOrder.Auto), iconImage: Expression<ImageValue> = nil(), iconOpacity: Expression<FloatValue> = const(1f), iconColor: Expression<ColorValue> = const(Color.Black), iconHaloColor: Expression<ColorValue> = const(Color.Transparent), iconHaloWidth: Expression<DpValue> = const(0.dp), iconHaloBlur: Expression<DpValue> = const(0.dp), iconSize: Expression<FloatValue> = const(1f), iconRotationAlignment: Expression<IconRotationAlignment> = const(IconRotationAlignment.Auto), iconPitchAlignment: Expression<IconPitchAlignment> = const(IconPitchAlignment.Auto), iconTextFit: Expression<IconTextFit> = const(IconTextFit.None), iconTextFitPadding: Expression<DpPaddingValue> = const(PaddingValues.Absolute(0.dp)), iconKeepUpright: Expression<BooleanValue> = const(false), iconRotate: Expression<FloatValue> = const(0f), iconAnchor: Expression<SymbolAnchor> = const(SymbolAnchor.Center), iconOffset: Expression<DpOffsetValue> = const(DpOffset.Zero), iconPadding: Expression<DpPaddingValue> = const(PaddingValues.Absolute(2.dp, 2.dp, 2.dp, 2.dp)), iconAllowOverlap: Expression<BooleanValue> = const(false), iconOverlap: Expression<StringValue> = nil(), iconIgnorePlacement: Expression<BooleanValue> = const(false), iconOptional: Expression<BooleanValue> = const(false), iconTranslate: Expression<DpOffsetValue> = const(DpOffset.Zero), iconTranslateAnchor: Expression<TranslateAnchor> = const(TranslateAnchor.Map), textField: Expression<FormattedValue> = const("").cast(), textOpacity: Expression<FloatValue> = const(1f), textColor: Expression<ColorValue> = const(Color.Black), textHaloColor: Expression<ColorValue> = const(Color.Transparent), textHaloWidth: Expression<DpValue> = const(0.dp), textHaloBlur: Expression<DpValue> = const(0.dp), textFont: Expression<ListValue<StringValue>> = LayerDefaults.FontNames, textSize: Expression<TextUnitValue> = const(1.em), textTransform: Expression<TextTransform> = const(TextTransform.None), textLetterSpacing: Expression<TextUnitValue> = const(0f.em), textRotationAlignment: Expression<TextRotationAlignment> = const(TextRotationAlignment.Auto), textPitchAlignment: Expression<TextPitchAlignment> = const(TextPitchAlignment.Auto), textMaxAngle: Expression<FloatValue> = const(45f), textMaxWidth: Expression<TextUnitValue> = const(10f.em), textLineHeight: Expression<TextUnitValue> = const(1.2f.em), textJustify: Expression<TextJustify> = const(TextJustify.Center), textWritingMode: Expression<ListValue<TextWritingMode>> = nil(), textKeepUpright: Expression<BooleanValue> = const(true), textRotate: Expression<FloatValue> = const(0f), textAnchor: Expression<SymbolAnchor> = const(SymbolAnchor.Center), textOffset: Expression<TextUnitOffsetValue> = offset(0f.em, 0f.em), textVariableAnchor: Expression<ListValue<SymbolAnchor>> = nil(), textRadialOffset: Expression<TextUnitValue> = const(0f.em), textVariableAnchorOffset: Expression<Nothing> = nil(), textPadding: Expression<DpValue> = const(2.dp), textAllowOverlap: Expression<BooleanValue> = const(false), textOverlap: Expression<SymbolOverlap> = nil(), textIgnorePlacement: Expression<BooleanValue> = const(false), textOptional: Expression<BooleanValue> = const(false), textTranslate: Expression<DpOffsetValue> = const(DpOffset.Zero), textTranslateAnchor: Expression<TranslateAnchor> = const(TranslateAnchor.Map), onClick: FeaturesClickHandler? = null, onLongClick: FeaturesClickHandler? = null)(source)

A symbol layer draws data from the sourceLayer in the given source as icons and/or text labels.

Parameters

id

Unique layer name.

source

Vector data source for this layer.

sourceLayer

Layer to use from the given vector tile source.

minZoom

The minimum zoom level for the layer. At zoom levels less than this, the layer will be hidden. A value in the range of [0..24].

maxZoom

The maximum zoom level for the layer. At zoom levels equal to or greater than this, the layer will be hidden. A value in the range of [0..24].

filter

An expression specifying conditions on source features. Only features that match the filter are displayed. Zoom expressions in filters are only evaluated at integer zoom levels. The featureState expression is not supported in filter expressions.

visible

Whether the layer should be displayed.

sortKey

Sorts features within this layer in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.

placement

Symbol placement relative to its geometry.

spacing

Distance between two symbol anchors.

Only applicable when placement is SymbolPlacement.Line.

avoidEdges

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.

zOrder

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 sortKey.

iconImage

Image to use for drawing an image background.

iconOpacity

The opacity at which the icon will be drawn. A value in the range [0..1].

Ignored if iconImage is not specified.

iconColor

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

Ignored if iconImage is not specified.

iconHaloColor

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

Ignored if iconImage is not specified.

iconHaloWidth

Distance of halo to the icon outline. The unit is in dp only for SDF sprites that were created with a blur radius of 8, multiplied by the display density. I.e., the radius needs to be 16 for @2x sprites, etc.

Ignored if iconImage is not specified.

iconHaloBlur

Fade out the halo towards the outside.

Ignored if iconImage is not specified.

iconSize

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.

Ignored if iconImage is not specified.

iconRotationAlignment

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

Ignored if iconImage is not specified.

iconPitchAlignment

Orientation of icon when map is pitched.

Ignored if iconImage is not specified.

iconTextFit

Scales the icon to fit around the associated text.

Ignored if not both iconImage and textField are specified.

iconTextFitPadding

Size of the additional area added to dimensions determined by iconTextFit.

Only applicable when if iconTextFit is not IconTextFit.None. Ignored if not both iconImage and textField are specified.

iconKeepUpright

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

Only applicable if iconRotationAlignment is IconRotationAlignment.Map and placement is either SymbolPlacement.Line or SymbolPlacement.LineCenter.

Ignored if iconImage is not specified.

iconRotate

Rotates the icon clockwise by the number in degrees.

Ignored if iconImage is not specified.

iconAnchor

Part of the icon placed closest to the anchor.

Ignored if iconImage is not specified.

iconOffset

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 dp. When combined with iconRotate the offset will be as if the rotated direction was up.

Ignored if iconImage is not specified.

iconPadding

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

Ignored if iconImage is not specified.

iconAllowOverlap

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

Ignored if iconImage is not specified, overridden by iconOverlap, if specified.

iconOverlap

Controls whether to show an icon when it overlaps other symbols on the map.

Ignored if iconImage is not specified.

Note: This property is not supported on native platforms yet, see maplibre-native#251**

iconIgnorePlacement

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

Ignored if iconImage is not specified.

iconOptional

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

Ignored if not both iconImage and textField are specified.

iconTranslate

The geometry's offset relative to the iconTranslateAnchor. Negative numbers indicate left and up, respectively.

Ignored if iconImage is not specified.

iconTranslateAnchor

Frame of reference for offsetting geometry.

Ignored if iconTranslate is not set.

textField

Value to use for a text label. Use e.g. format(const("My label")) to display the plain string "My label".

The text can also be formatted, employing different colors, fonts, etc., see format.

textOpacity

The opacity at which the text will be drawn.

Ignored if textField is not specified.

textColor

The color with which the text will be drawn.

Ignored if textField is not specified.

textHaloColor

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

Ignored if textField is not specified.

textHaloWidth

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

Ignored if textField is not specified.

textHaloBlur

The halo's fadeout distance towards the outside.

Ignored if textField is not specified.

textFont

Font stack to use for displaying text.

Ignored if textField is not specified.

textSize

Font size in SP or EM relative to 16sp.

Ignored if textField is not specified.

Important: If using zoom interpolation for text size, then all other properties defined in text units (like textLetterSpacing, textOffset, etc) MUST be defined in EM units, not SP units. This is a limitation of the MapLibre expression parser. If text size does not use zoom interpolation, then those other properties can be defined in either unit.

textTransform

Specifies how to capitalize text.

textLetterSpacing

Text tracking amount.

Ignored if textField is not specified.

textRotationAlignment

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

Ignored if textField is not specified.

textPitchAlignment

Orientation of text when map is pitched.

Ignored if textField is not specified.

textMaxAngle

Maximum angle change in degrees between adjacent characters.

Only applicable if placement is SymbolPlacement.Line or SymbolPlacement.LineCenter

Ignored if textField is not specified.

textMaxWidth

The maximum line width for text wrapping.

Ignored if textField is not specified.

textLineHeight

Text leading value for multi-line text.

Ignored if textField is not specified.

textJustify

Text justification options.

Ignored if textField is not specified.

textWritingMode

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.

Ignored if textField is not specified.

textKeepUpright

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

Only applicable if textRotationAlignment is TextRotationAlignment.Map and placement is SymbolPlacement.Line or SymbolPlacement.LineCenter

Ignored if textField is not specified.

textRotate

Rotates the text clockwise. Unit in degrees.

Ignored if textField is not specified.

textAnchor

Part of the text placed closest to the anchor.

Overridden by textVariableAnchorOffset.

Ignored if textField is not specified.

textOffset

Offset distance of text from its anchor in ems. 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 y-axis will be applied automatically based on the anchor position.

Overridden by textRadialOffset.

Ignored if textField is not specified.

textVariableAnchor

To increase the chance of placing high-priority 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 = TextJustify.Auto to choose justification based on anchor position. To apply an offset, use the textRadialOffset or the two-dimensional textOffset.

Only applicable if placement is SymbolPlacement.Point.

Ignored if textField is not specified.

textRadialOffset

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

Ignored if textField is not specified.

textVariableAnchorOffset

To increase the chance of placing high-priority labels on the map, you can provide an array of SymbolAnchor locations, each paired with an offset value. The renderer will attempt to place the label at each location, in order, before moving on to the next location+offset. Use textJustify = TextJustify.Auto to choose justification based on anchor position.

Each anchor location is accompanied by a point which defines the offset when the corresponding anchor location is used. Positive offset values indicate right and down, while negative values indicate left and up. Anchor locations may repeat, allowing the renderer to try multiple offsets to try and place a label using the same anchor.

When present, this property takes precedence over textAnchor, textVariableAnchor, textOffset and textRadialOffset.

Example:

listOf(
SymbolAnchor.Top to Point(0, 4),
SymbolAnchor.Left to Point(3, 0),
SymbolAnchor.Bottom to Point(1, 1)
)

When the renderer chooses the top anchor, 0, 4 will be used for textOffset; the text will be shifted down by 4 ems. When the renderer chooses the left anchor, 3, 0 will be used for textOffset; the text will be shifted right by 3 ems. Etc.

Ignored if textField is not specified.

NOTE: This property is currently not usable: https://github.com/maplibre/maplibre-compose/issues/143

textPadding

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

Ignored if textField is not specified.

textAllowOverlap

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

Overridden by textOverlap.

Ignored if textField is not specified.

textOverlap

Controls whether to show an icon/text when it overlaps other symbols on the map. See SymbolOverlap. Overrides textAllowOverlap.

Ignored if textField is not specified.

Note: This property is not supported on native platforms, yet, see maplibre-native#251**

textIgnorePlacement

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

Ignored if textField is not specified.

textOptional

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

Ignored if not both textField and iconImage are specified.

textTranslate

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

Ignored if textField is not specified.

textTranslateAnchor

Controls the frame of reference for textTranslate.

Ignored if textField is not specified.

onClick

Function to call when any feature in this layer has been clicked.

onLongClick

Function to call when any feature in this layer has been long-clicked.