Class: Icon

ol.style.Icon

Set icon style for vector features.

new ol.style.Icon(opt_options) experimental

src/ol/style/iconstyle.js, line 50
Name Type Description
options

Options.

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

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

anchorOrigin ol.style.IconOrigin | undefined experimental

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

anchorXUnits ol.style.IconAnchorUnits | undefined experimental

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 experimental

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 experimental

The crossOrigin attribute for loaded images. Note that you must provide a crossOrigin value if you are using the WebGL renderer or 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 Image | undefined experimental

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 size option.

offset Array.<number> | undefined experimental

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 experimental

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

opacity number | undefined experimental

Opacity of the icon. Default is 1.

scale number | undefined experimental

Scale.

snapToPixel boolean | undefined experimental

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 experimental

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

rotation number | undefined experimental

Rotation.

size ol.Size | undefined experimental

Icon size in pixel. Can be used together with offset to define the sub-rectangle to use from the origin (sprite) icon image. Also, setting the size is required if img is set and src is not.

src string experimental

Image source URI.

Extends

Methods

getAnchor(){Array.<number>} experimental

src/ol/style/iconstyle.js, line 189
Returns:
Anchor.

getImage(pixelRatio){Image} experimental

src/ol/style/iconstyle.js, line 235
Name Type Description
pixelRatio number

Pixel ratio.

Returns:
Image element.

getOpacity(){number} inherited experimental

src/ol/style/imagestyle.js, line 75
Returns:
Opacity.

getOrigin(){Array.<number>} experimental

src/ol/style/iconstyle.js, line 277
Returns:
Origin.

getRotateWithView(){boolean} inherited experimental

src/ol/style/imagestyle.js, line 84
Returns:
Rotate with map.

getRotation(){number} inherited experimental

src/ol/style/imagestyle.js, line 93
Returns:
Rotation.

getScale(){number} inherited experimental

src/ol/style/imagestyle.js, line 102
Returns:
Scale.

getSize(){ol.Size} experimental

src/ol/style/iconstyle.js, line 317
Returns:
Size.

getSnapToPixel(){boolean} inherited experimental

src/ol/style/imagestyle.js, line 111
Returns:
Snap to pixel?

getSrc(){string|undefined} experimental

src/ol/style/iconstyle.js, line 308
Returns:
Image src.

setRotation(rotation) inherited experimental

src/ol/style/imagestyle.js, line 197

Set the rotation.

Name Type Description
rotation number

Rotation.

setScale(scale) inherited experimental

src/ol/style/imagestyle.js, line 208

Set the scale.

Name Type Description
scale number

Scale.