MapboxGL.SymbolLayer

<MapboxGL.SymbolLayer />

SymbolLayer is a style layer that renders icon and text labels at points or along lines on the map.
SymbolLayer是在地图上的点处或沿线渲染图标和文本标签的样式图层。

props

Prop Type Default Required Description
id string none false A string that uniquely identifies the source in the style to which it is added.
sourceID string MapboxGL.StyleSource.DefaultSourceID false 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.
sourceLayerID string none false Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
aboveLayerID string none false Inserts a layer above aboveLayerID.
belowLayerID string none false Inserts a layer below belowLayerID
layerIndex number none false Inserts a layer at a specified index
filter array none false Filter only the features in the source layer that satisfy a condition that you define
minZoomLevel number none false The minimum zoom level at which the layer gets parsed and appears.
maxZoomLevel number none false The maximum zoom level at which the layer gets parsed and appears.
style union none false Customizable style attributes

styles

  • <a href="#name">symbolPlacement</a> 符号位置
  • <a href="#name-1">symbolSpacing</a> 符号空格
  • <a href="#name-2">symbolAvoidEdges</a> 符号避免边缘
  • <a href="#name-3">symbolZOrder</a> 符号顺序
  • <a href="#name-4">iconAllowOverlap</a> 图标允许重叠
  • <a href="#name-5">iconIgnorePlacement</a> 忽略放置
  • <a href="#name-6">iconOptional</a> 可选项
  • <a href="#name-7">iconRotationAlignment</a> 符号旋转对齐
  • <a href="#name-8">iconSize</a> 大小
  • <a href="#name-9">iconTextFit</a> 文字匹配
  • <a href="#name-10">iconTextFitPadding</a> 文字匹配边距
  • <a href="#name-11">iconImage</a> 图片
  • <a href="#name-12">iconRotate</a> 旋转
  • <a href="#name-13">iconPadding</a> 边距
  • <a href="#name-14">iconKeepUpright</a> 保持直立
  • <a href="#name-15">iconOffset</a> 偏移量
  • <a href="#name-16">iconAnchor</a> 锚点
  • <a href="#name-17">iconPitchAlignment</a> 符号倾斜对齐
  • <a href="#name-18">textPitchAlignment</a> 文字倾斜对齐
  • <a href="#name-19">textRotationAlignment</a> 文字旋转对齐
  • <a href="#name-20">textField</a> 字段
  • <a href="#name-21">textFont</a> 字体
  • <a href="#name-22">textSize</a> 大小
  • <a href="#name-23">textMaxWidth</a> 最大宽度
  • <a href="#name-24">textLineHeight</a>
  • <a href="#name-25">textLetterSpacing</a> 字母间距
  • <a href="#name-26">textJustify</a>
  • <a href="#name-27">textAnchor</a> 文字锚点
  • <a href="#name-28">textMaxAngle</a> 文字最大角度
  • <a href="#name-29">textRotate</a> 文字旋转
  • <a href="#name-30">textPadding</a> 文字边距
  • <a href="#name-31">textKeepUpright</a> 文字保持直立
  • <a href="#name-32">textTransform</a> 文字转换量
  • <a href="#name-33">textOffset</a> 文字偏移量
  • <a href="#name-34">textAllowOverlap</a> 文字允许重叠
  • <a href="#name-35">textIgnorePlacement</a> 文字忽略放置
  • <a href="#name-36">textOptional</a> 文字可选项
  • <a href="#name-37">visibility</a> 是否可见
  • <a href="#name-38">iconOpacity</a> 透明度
  • <a href="#name-39">iconColor</a> 颜色
  • <a href="#name-40">iconHaloColor</a> 光晕颜色
  • <a href="#name-41">iconHaloWidth</a> 光晕宽度
  • <a href="#name-42">iconHaloBlur</a> 光晕模糊度
  • <a href="#name-43">iconTranslate</a> 符号翻转
  • <a href="#name-44">iconTranslateAnchor</a> 符号翻转锚点
  • <a href="#name-45">textOpacity</a> 文字透明度
  • <a href="#name-46">textColor</a> 文字颜色
  • <a href="#name-47">textHaloColor</a> 文字光晕颜色
  • <a href="#name-48">textHaloWidth</a> 文字光晕宽度
  • <a href="#name-49">textHaloBlur</a> 文字光晕模糊度
  • <a href="#name-50">textTranslate</a> 文字翻转
  • <a href="#name-51">textTranslateAnchor</a> 文字翻转锚点

Name

symbolPlacement

Description

Label placement relative to its geometry.

Type

enum

Default Value

point

Supported Values

point - The label is placed at the point where the geometry is located.<br />
line - The label is placed along the line of the geometry. Can only be used on LineString and Polygon geometries.<br />
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.<br />

Expression

Parameters: zoom


Name

symbolSpacing

Description

Distance between two symbol anchors.

Type

number

Default Value

250

Units

pixels

Minimum

1

Expression

Parameters: zoom


Name

symbolAvoidEdges

Description

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.

Type

boolean

Default Value

false

Expression

Parameters: zoom


Name

symbolZOrder

Description

Controls the order in which overlapping symbols in the same layer are rendered

Type

enum

Default Value

auto

Supported Values

auto - If symbol-sort-key is set, sort based on that. Otherwise sort symbols by their y-position relative to the viewport.<br />
viewport-y - Symbols will be sorted by their y-position relative to the viewport.<br />
source - Symbols will be rendered in the same order as the source data with no sorting applied.<br />

Expression

Parameters: zoom


Name

iconAllowOverlap

Description

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

Type

boolean

Default Value

false

Requires

iconImage

Expression

Parameters: zoom


Name

iconIgnorePlacement

Description

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

Type

boolean

Default Value

false

Requires

iconImage

Expression

Parameters: zoom


Name

iconOptional

Description

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

Type

boolean

Default Value

false

Requires

iconImage, textField

Expression

Parameters: zoom


Name

iconRotationAlignment

Description

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

Type

enum

Default Value

auto

Supported Values

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.<br />
viewport - Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of symbol-placement.<br />
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.<br />

Requires

iconImage

Expression

Parameters: zoom


Name

iconSize

Description

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.

Type

number

Default Value

1

Units

factor of the original icon size

Minimum

0

Requires

iconImage

Expression

Parameters: zoom, feature


Name

iconTextFit

Description

Scales the icon to fit around the associated text.

Type

enum

Default Value

none

Supported Values

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

Requires

iconImage, textField

Expression

Parameters: zoom


Name

iconTextFitPadding

Description

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

Type

array<number>

Default Value

[0,0,0,0]

Units

pixels

Requires

iconImage, textField

Expression

Parameters: zoom


Name

iconImage

Description

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

Type

string

Expression

Parameters: zoom, feature


Name

iconRotate

Description

Rotates the icon clockwise.

Type

number

Default Value

0

Units

degrees

Requires

iconImage

Expression

Parameters: zoom, feature


Name

iconPadding

Description

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

Type

number

Default Value

2

Units

pixels

Minimum

0

Requires

iconImage

Expression

Parameters: zoom


Name

iconKeepUpright

Description

If true, the icon may be flipped to prevent it from being rendered upsideDown.

Type

boolean

Default Value

false

Requires

iconImage

Expression

Parameters: zoom


Name

iconOffset

Description

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.

Type

array<number>

Default Value

[0,0]

Requires

iconImage

Expression

Parameters: zoom, feature


Name

iconAnchor

Description

Part of the icon placed closest to the anchor.

Type

enum

Default Value

center

Supported Values

center - The center of the icon is placed closest to the anchor.<br />
left - The left side of the icon is placed closest to the anchor.<br />
right - The right side of the icon is placed closest to the anchor.<br />
top - The top of the icon is placed closest to the anchor.<br />
bottom - The bottom of the icon is placed closest to the anchor.<br />
top-left - The top left corner of the icon is placed closest to the anchor.<br />
top-right - The top right corner of the icon is placed closest to the anchor.<br />
bottom-left - The bottom left corner of the icon is placed closest to the anchor.<br />
bottom-right - The bottom right corner of the icon is placed closest to the anchor.<br />

Requires

iconImage

Expression

Parameters: zoom, feature


Name

iconPitchAlignment

Description

Orientation of icon when map is pitched.

Type

enum

Default Value

auto

Supported Values

map - The icon is aligned to the plane of the map.<br />
viewport - The icon is aligned to the plane of the viewport.<br />
auto - Automatically matches the value of icon-rotation-alignment.<br />

Requires

iconImage

Expression

Parameters: zoom


Name

textPitchAlignment

Description

Orientation of text when map is pitched.

Type

enum

Default Value

auto

Supported Values

map - The text is aligned to the plane of the map.<br />
viewport - The text is aligned to the plane of the viewport.<br />
auto - Automatically matches the value of text-rotation-alignment.<br />

Requires

textField

Expression

Parameters: zoom


Name

textRotationAlignment

Description

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

Type

enum

Default Value

auto

Supported Values

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.<br />
viewport - Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of symbol-placement.<br />
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.<br />

Requires

textField

Expression

Parameters: zoom


Name

textField

Description

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.

Type

formatted

Default Value

``

Expression

Parameters: zoom, feature


Name

textFont

Description

Font stack to use for displaying text.

Type

array<string>

Default Value

[Open Sans Regular,Arial Unicode MS Regular]

Requires

textField

Supported Style Functions

camera

Expression

Parameters: zoom, feature


Name

textSize

Description

Font size.

Type

number

Default Value

16

Units

pixels

Minimum

0

Requires

textField

Expression

Parameters: zoom, feature


Name

textMaxWidth

Description

The maximum line width for text wrapping.

Type

number

Default Value

10

Units

ems

Minimum

0

Requires

textField

Supported Style Functions

camera

Expression

Parameters: zoom, feature


Name

textLineHeight

Description

Text leading value for multiLine text.

Type

number

Default Value

1.2

Units

ems

Requires

textField

Expression

Parameters: zoom


Name

textLetterSpacing

Description

Text tracking amount.

Type

number

Default Value

0

Units

ems

Requires

textField

Supported Style Functions

camera

Expression

Parameters: zoom, feature


Name

textJustify

Description

Text justification options.

Type

enum

Default Value

center

Supported Values

auto - The text is aligned towards the anchor position.<br />
left - The text is aligned to the left.<br />
center - The text is centered.<br />
right - The text is aligned to the right.<br />

Requires

textField

Supported Style Functions

camera

Expression

Parameters: zoom, feature


Name

textAnchor

Description

Part of the text placed closest to the anchor.

Type

enum

Default Value

center

Supported Values

center - The center of the text is placed closest to the anchor.<br />
left - The left side of the text is placed closest to the anchor.<br />
right - The right side of the text is placed closest to the anchor.<br />
top - The top of the text is placed closest to the anchor.<br />
bottom - The bottom of the text is placed closest to the anchor.<br />
top-left - The top left corner of the text is placed closest to the anchor.<br />
top-right - The top right corner of the text is placed closest to the anchor.<br />
bottom-left - The bottom left corner of the text is placed closest to the anchor.<br />
bottom-right - The bottom right corner of the text is placed closest to the anchor.<br />

Requires

textField

Supported Style Functions

camera

Expression

Parameters: zoom, feature


Name

textMaxAngle

Description

Maximum angle change between adjacent characters.

Type

number

Default Value

45

Units

degrees

Requires

textField

Expression

Parameters: zoom


Name

textRotate

Description

Rotates the text clockwise.

Type

number

Default Value

0

Units

degrees

Requires

textField

Expression

Parameters: zoom, feature


Name

textPadding

Description

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

Type

number

Default Value

2

Units

pixels

Minimum

0

Requires

textField

Expression

Parameters: zoom


Name

textKeepUpright

Description

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

Type

boolean

Default Value

true

Requires

textField

Expression

Parameters: zoom


Name

textTransform

Description

Specifies how to capitalize text, similar to the CSS textTransform property.

Type

enum

Default Value

none

Supported Values

none - The text is not altered.<br />
uppercase - Forces all letters to be displayed in uppercase.<br />
lowercase - Forces all letters to be displayed in lowercase.<br />

Requires

textField

Expression

Parameters: zoom, feature


Name

textOffset

Description

Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up.

Type

array<number>

Default Value

[0,0]

Units

ems

Requires

textField

Disabled By

textRadialOffset

Expression

Parameters: zoom, feature


Name

textAllowOverlap

Description

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

Type

boolean

Default Value

false

Requires

textField

Expression

Parameters: zoom


Name

textIgnorePlacement

Description

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

Type

boolean

Default Value

false

Requires

textField

Expression

Parameters: zoom


Name

textOptional

Description

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

Type

boolean

Default Value

false

Requires

textField, iconImage

Expression

Parameters: zoom


Name

visibility

Description

Whether this layer is displayed.

Type

enum

Default Value

visible

Supported Values

visible - The layer is shown.<br />
none - The layer is not shown.<br />


Name

iconOpacity

Description

The opacity at which the icon will be drawn.

Type

number

Default Value

1

Minimum

0

Maximum

1

Requires

iconImage

Expression

Parameters: zoom, feature, feature-state


Name

iconColor

Description

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

Type

color

Default Value

#000000

Requires

iconImage

Expression

Parameters: zoom, feature, feature-state


Name

iconHaloColor

Description

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

Type

color

Default Value

rgba(0, 0, 0, 0)

Requires

iconImage

Expression

Parameters: zoom, feature, feature-state


Name

iconHaloWidth

Description

Distance of halo to the icon outline.

Type

number

Default Value

0

Units

pixels

Minimum

0

Requires

iconImage

Expression

Parameters: zoom, feature, feature-state


Name

iconHaloBlur

Description

Fade out the halo towards the outside.

Type

number

Default Value

0

Units

pixels

Minimum

0

Requires

iconImage

Expression

Parameters: zoom, feature, feature-state


Name

iconTranslate

Description

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.

Type

array<number>

Default Value

[0,0]

Units

pixels

Requires

iconImage

Expression

Parameters: zoom


Name

iconTranslateAnchor

Description

Controls the frame of reference for iconTranslate.

Type

enum

Default Value

map

Supported Values

map - Icons are translated relative to the map.<br />
viewport - Icons are translated relative to the viewport.<br />

Requires

iconImage, iconTranslate

Expression

Parameters: zoom


Name

textOpacity

Description

The opacity at which the text will be drawn.

Type

number

Default Value

1

Minimum

0

Maximum

1

Requires

textField

Expression

Parameters: zoom, feature, feature-state


Name

textColor

Description

The color with which the text will be drawn.

Type

color

Default Value

#000000

Requires

textField

Expression

Parameters: zoom, feature, feature-state


Name

textHaloColor

Description

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

Type

color

Default Value

rgba(0, 0, 0, 0)

Requires

textField

Expression

Parameters: zoom, feature, feature-state


Name

textHaloWidth

Description

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

Type

number

Default Value

0

Units

pixels

Minimum

0

Requires

textField

Expression

Parameters: zoom, feature, feature-state


Name

textHaloBlur

Description

The halo's fadeout distance towards the outside.

Type

number

Default Value

0

Units

pixels

Minimum

0

Requires

textField

Expression

Parameters: zoom, feature, feature-state


Name

textTranslate

Description

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.

Type

array<number>

Default Value

[0,0]

Units

pixels

Requires

textField

Expression

Parameters: zoom


Name

textTranslateAnchor

Description

Controls the frame of reference for textTranslate.

Type

enum

Default Value

map

Supported Values

map - The text is translated relative to the map.<br />
viewport - The text is translated relative to the viewport.<br />

Requires

textField, textTranslate

Expression

Parameters: zoom

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,701评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,649评论 3 396
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 166,037评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,994评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,018评论 6 395
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,796评论 1 308
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,481评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,370评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,868评论 1 319
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,014评论 3 338
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,153评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,832评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,494评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,039评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,156评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,437评论 3 373
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,131评论 2 356