Module: ol/style/Icon

ol/style/Icon


Classes

Icon

Type Definitions

IconAnchorUnits{'fraction'} {'pixels'}

Anchor unit can be either a fraction of the icon size or in pixels.

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

Icon origin. One of 'bottom-left', 'bottom-right', 'top-left', 'top-right'.

Options{Object}

Properties:
Name Type Description
anchor Array.<number>
(defaults to [0.5, 0.5])

Anchor. Default value is the icon center.

anchorOrigin IconOrigin
(defaults to 'top-left')

Origin of the anchor: bottom-left, bottom-right, top-left or top-right.

anchorXUnits IconAnchorUnits
(defaults to 'fraction')

Units in which the anchor x value is specified. A value of 'fraction' indicates the x value is a fraction of the icon. A value of 'pixels' indicates the x value in pixels.

anchorYUnits IconAnchorUnits
(defaults to 'fraction')

Units in which the anchor y value is specified. A value of 'fraction' indicates the y value is a fraction of the icon. A value of 'pixels' indicates the y value in pixels.

color Color | string | undefined

Color to tint the icon. If not specified, the icon will be left as is.

crossOrigin null | string | undefined

The crossOrigin attribute for loaded images. Note that you must provide a crossOrigin value if you want to access pixel data with the Canvas renderer. See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

img HTMLImageElement | HTMLCanvasElement | ImageBitmap | undefined

Image object for the icon.

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

Displacement of the icon in pixels. Positive values will shift the icon right and up.

opacity number
(defaults to 1)

Opacity of the icon.

width number | undefined

The width of the icon in pixels. This can't be used together with scale.

height number | undefined

The height of the icon in pixels. This can't be used together with scale.

scale number | Size
(defaults to 1)

Scale.

rotateWithView boolean
(defaults to false)

Whether to rotate the icon with the view.

rotation number
(defaults to 0)

Rotation in radians (positive rotation clockwise).

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

Offset which, together with size and offsetOrigin, defines the sub-rectangle to use from the original (sprite) image.

offsetOrigin IconOrigin
(defaults to 'top-left')

Origin of the offset: bottom-left, bottom-right, top-left or top-right.

size Size | undefined

Icon size in pixels. Used together with offset to define the sub-rectangle to use from the original (sprite) image.

src string | undefined

Image source URI.

declutterMode DeclutterMode | undefined

Declutter mode.