模块:ol/style/Icon

ol/style/Icon


Icon

类型定义

IconAnchorUnits{'fraction'} {'pixels'}

锚点单位既可以是图标尺寸的分数,也可以是以像素为单位。

IconOrigin{'bottom-left'} {'bottom-right'} {'top-left'} {'top-right'}

图标原点,可选值包括:'bottom-left'、'bottom-right'、'top-left'、'top-right' 之一。

Options{Object}

属性:
Name Type 描述
anchor Array.<number>
(defaults to [0.5, 0.5])

锚点:默认值为图标中心。

anchorOrigin IconOrigin
(defaults to 'top-left')

锚点来源:bottom-left, bottom-right, top-lefttop-right.

anchorXUnits IconAnchorUnits
(defaults to 'fraction')

锚点 x 值的指定单位。值为'fraction'表示x值是图标的比例。值为'pixels'指示 x 值(以像素为单位)。

anchorYUnits IconAnchorUnits
(defaults to 'fraction')

锚点y值的单位。值为'fraction'表示 y 值是图标的比例。值为'pixels'表示y值(以像素为单位)。

color Color | string | undefined

用于图标着色的颜色。如果未指定,图标将保持原样。

crossOrigin null | string | undefined

crossOrigin 表示已加载图像的属性。请注意,您必须提供 crossOrigin。若要通过 Canvas 渲染器访问像素数据,请使用此值。请参考 https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image 查看更详细信息。

img HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | undefined

用于图标的图像对象。

displacement Array.<number>
(defaults to [0, 0])

图标的偏移量(以像素为单位)。正值将使图标向右和向上偏移。

opacity number
(defaults to 1)

图标的不透明度。

width number | undefined

图标宽度(像素)。此设置不能与以下选项同时使用。scale.

height number | undefined

图标高度(以像素为单位)。此属性不能与以下选项同时使用。scale.

scale number | Size
(defaults to 1)

比例.

rotateWithView boolean
(defaults to false)

图标是否随视图旋转。

rotation number
(defaults to 0)

旋转角度以弧度为单位(顺时针为正)。

offset Array.<number>
(defaults to [0, 0])

偏移量,连同sizeoffsetOrigin定义原始(精灵)图像中要使用的子矩形。

offsetOrigin IconOrigin
(defaults to 'top-left')

偏移量来源:bottom-left, bottom-right, top-left或者top-right.

size Size | undefined

图标大小(以像素为单位)。需配合使用。offset定义从原始(精灵)图像中使用的子矩形。

src string | undefined

图像源URI。

declutterMode DeclutterMode | undefined

整理模式。