Module: ol/style/Icon

ol/style/Icon


Classes

Icon

Type Definitions

Options{Object}

Properties:
Name Type Argument Default Description
anchor Array.<number> <optional>
[0.5, 0.5]

Anchor. Default value is the icon center.

anchorOrigin module:ol/style/IconOrigin <optional>
'top-left'

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

anchorXUnits module:ol/style/IconAnchorUnits <optional>
'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 module:ol/style/IconAnchorUnits <optional>
'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 module:ol/color~Color | string <optional>

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

crossOrigin null | string <optional>

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 <optional>

Image object for the icon. If the src option is not provided then the provided image must already be loaded. And in that case, it is required to provide the size of the image, with the imgSize option.

offset Array.<number> <optional>
[0, 0]

Offset, which, together with the size and the offset origin, define the sub-rectangle to use from the original icon image.

displacement Array.<number> <optional>
[0,0]

Displacement the icon

offsetOrigin module:ol/style/IconOrigin <optional>
'top-left'

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

opacity number <optional>
1

Opacity of the icon.

scale number | module:ol/size~Size <optional>
1

Scale.

rotateWithView boolean <optional>
false

Whether to rotate the icon with the view.

rotation number <optional>
0

Rotation in radians (positive rotation clockwise).

size module:ol/size~Size <optional>

Icon size in pixel. Can be used together with offset to define the sub-rectangle to use from the origin (sprite) icon image.

imgSize module:ol/size~Size <optional>

Image size in pixels. Only required if img is set and src is not, and for SVG images in Internet Explorer 11. The provided imgSize needs to match the actual size of the image.

src string <optional>

Image source URI.