Class: Stroke

ol/style/Stroke~Stroke


import Stroke from 'ol/style/Stroke';

Set stroke style for vector features. Note that the defaults given are the Canvas defaults, which will be used if option is not defined. The get functions return whatever was entered in the options; they will not return the default.

new Stroke(opt_options)

style/Stroke.js, line 34
Name Type Description
options

Options.

Name Type Description
color module:ol/color~Color | module:ol/colorlike~ColorLike

A color, gradient or pattern. See module:ol/color~Color and module:ol/colorlike~ColorLike for possible formats. Default null; if null, the Canvas/renderer default black will be used.

lineCap CanvasLineCap (defaults to 'round')

Line cap style: butt, round, or square.

lineJoin CanvasLineJoin (defaults to 'round')

Line join style: bevel, round, or miter.

lineDash Array.<number>

Line dash pattern. Default is undefined (no dash). Please note that Internet Explorer 10 and lower do not support the setLineDash method on the CanvasRenderingContext2D and therefore this option will have no visual effect in these browsers.

lineDashOffset number (defaults to 0)

Line dash offset.

miterLimit number (defaults to 10)

Miter limit.

width number

Width.

Methods

clone(){module:ol/style/Stroke~Stroke}

style/Stroke.js, line 86

Clones the style.

Returns:
The cloned style.

getColor(){module:ol/color~Color|module:ol/colorlike~ColorLike}

style/Stroke.js, line 104

Get the stroke color.

Returns:
Color.

getLineCap(){CanvasLineCap|undefined}

style/Stroke.js, line 113

Get the line cap type for the stroke.

Returns:
Line cap.

getLineDash(){Array.<number>}

style/Stroke.js, line 122

Get the line dash style for the stroke.

Returns:
Line dash.

getLineDashOffset(){number|undefined}

style/Stroke.js, line 131

Get the line dash offset for the stroke.

Returns:
Line dash offset.

getLineJoin(){CanvasLineJoin|undefined}

style/Stroke.js, line 140

Get the line join type for the stroke.

Returns:
Line join.

getMiterLimit(){number|undefined}

style/Stroke.js, line 149

Get the miter limit for the stroke.

Returns:
Miter limit.

getWidth(){number|undefined}

style/Stroke.js, line 158

Get the stroke width.

Returns:
Width.

setColor(color)

style/Stroke.js, line 168

Set the color.

Name Type Description
color module:ol/color~Color | module:ol/colorlike~ColorLike

Color.

setLineCap(lineCap)

style/Stroke.js, line 178

Set the line cap.

Name Type Description
lineCap CanvasLineCap | undefined

Line cap.

setLineDash(lineDash)

style/Stroke.js, line 194

Set the line dash.

Please note that Internet Explorer 10 and lower do not support the setLineDash method on the CanvasRenderingContext2D and therefore this property will have no visual effect in these browsers.

Name Type Description
lineDash Array.<number>

Line dash.

setLineDashOffset(lineDashOffset)

style/Stroke.js, line 204

Set the line dash offset.

Name Type Description
lineDashOffset number | undefined

Line dash offset.

setLineJoin(lineJoin)

style/Stroke.js, line 214

Set the line join.

Name Type Description
lineJoin CanvasLineJoin | undefined

Line join.

setMiterLimit(miterLimit)

style/Stroke.js, line 224

Set the miter limit.

Name Type Description
miterLimit number | undefined

Miter limit.

setWidth(width)

style/Stroke.js, line 234

Set the width.

Name Type Description
width number | undefined

Width.