Class: Icon

Icon

Set icon style for vector features.

new ol.style.Icon(opt_options) experimental

Name Type Description
options optional

Options.

Name Type Description
anchor Array.<number> | undefined optional

Anchor. Default value is [0.5, 0.5] (icon center).

anchorOrigin ol.style.IconOrigin | undefined optional

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

anchorXUnits ol.style.IconAnchorUnits | undefined optional

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. Default is 'fraction'.

anchorYUnits ol.style.IconAnchorUnits | undefined optional

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. Default is 'fraction'.

crossOrigin null | string | undefined optional

crossOrigin setting for image.

img Image | undefined optional

Image object for the icon. If the src option is not provided then the provided image must already be loaded.

offset Array.<number> | undefined optional

Offset, which, together with the size and the offset origin, define the sub-rectangle to use from the original icon image. Default value is [0, 0].

offsetOrigin ol.style.IconOrigin | undefined optional

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

scale number | undefined optional

Scale.

snapToPixel boolean | undefined optional

If true integral numbers of pixels are used as the X and Y pixel coordinate when drawing the icon in the output canvas. If false fractional numbers may be used. Using true allows for "sharp" rendering (no blur), while using false allows for "accurate" rendering. Note that accuracy is important if the icon's position is animated. Without it, the icon may jitter noticeably. Default value is true.

rotateWithView boolean | undefined optional

Whether to rotate the icon with the view. Default is false.

rotation number | undefined optional

Rotation.

size ol.Size | undefined optional

Icon size in pixel.

src string

Image source URI.

Extends

Methods

getAnchor(){Array.<number>} experimental

Returns:
Anchor.

getImage(pixelRatio){HTMLCanvasElement|HTMLVideoElement|Image} experimental

Name Type Description
pixelRatio number

Pixel ratio.

Returns:
Image element.

getOrigin(){Array.<number>} experimental

Returns:
Origin.

getRotation(){number} inherited experimental

Returns:
Rotation.

getScale(){number} inherited experimental

Returns:
Scale.

getSize(){ol.Size} experimental

Returns:
Size.

getSrc(){string|undefined} experimental

Returns:
Image src.