Class: Text

ol.style.Text

Set text style for vector features.

new ol.style.Text(opt_options) experimental

src/ol/style/textstyle.js, line 15
Name Type Description
options

Options.

Name Type Description
font string | undefined experimental

Font style as CSS 'font' value, see: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font. Default is '10px sans-serif'

offsetX number | undefined experimental

Horizontal text offset in pixels. A positive will shift the text right. Default is 0.

offsetY number | undefined experimental

Vertical text offset in pixels. A positive will shift the text down. Default is 0.

scale number | undefined experimental

Scale.

rotation number | undefined experimental

Rotation in radians (positive rotation clockwise). Default is 0.

text string | undefined experimental

Text content.

textAlign string | undefined experimental

Text alignment. Possible values: 'left', 'right', 'center', 'end' or 'start'. Default is 'start'.

textBaseline string | undefined experimental

Text base line. Possible values: 'bottom', 'top', 'middle', 'alphabetic', 'hanging', 'ideographic'. Default is 'alphabetic'.

fill ol.style.Fill | undefined experimental

Fill style. If none is provided, we'll use a dark fill-style (#333).

stroke ol.style.Stroke | undefined experimental

Stroke style.

Methods

getFill(){ol.style.Fill} experimental

src/ol/style/textstyle.js, line 127

Get the fill style for the text.

Returns:
Fill style.

getFont(){string|undefined} experimental

src/ol/style/textstyle.js, line 97

Get the font name.

Returns:
Font.

getOffsetX(){number} experimental

src/ol/style/textstyle.js, line 107

Get the x-offset for the text.

Returns:
Horizontal text offset.

getOffsetY(){number} experimental

src/ol/style/textstyle.js, line 117

Get the y-offset for the text.

Returns:
Vertical text offset.

getRotation(){number|undefined} experimental

src/ol/style/textstyle.js, line 137

Get the text rotation.

Returns:
Rotation.

getScale(){number|undefined} experimental

src/ol/style/textstyle.js, line 147

Get the text scale.

Returns:
Scale.

getStroke(){ol.style.Stroke} experimental

src/ol/style/textstyle.js, line 157

Get the stroke style for the text.

Returns:
Stroke style.

getText(){string|undefined} experimental

src/ol/style/textstyle.js, line 167

Get the text to be rendered.

Returns:
Text.

getTextAlign(){string|undefined} experimental

src/ol/style/textstyle.js, line 177

Get the text alignment.

Returns:
Text align.

getTextBaseline(){string|undefined} experimental

src/ol/style/textstyle.js, line 187

Get the text baseline.

Returns:
Text baseline.

setFill(fill) experimental

src/ol/style/textstyle.js, line 231

Set the fill.

Name Type Description
fill ol.style.Fill

Fill style.

setFont(font) experimental

src/ol/style/textstyle.js, line 198

Set the font.

Name Type Description
font string | undefined

Font.

setOffsetX(offsetX) experimental

src/ol/style/textstyle.js, line 209

Set the x offset.

Name Type Description
offsetX number

Horizontal text offset.

setOffsetY(offsetY) experimental

src/ol/style/textstyle.js, line 220

Set the y offset.

Name Type Description
offsetY number

Vertical text offset.

setRotation(rotation) experimental

src/ol/style/textstyle.js, line 242

Set the rotation.

Name Type Description
rotation number | undefined

Rotation.

setScale(scale) experimental

src/ol/style/textstyle.js, line 253

Set the scale.

Name Type Description
scale number | undefined

Scale.

setStroke(stroke) experimental

src/ol/style/textstyle.js, line 264

Set the stroke.

Name Type Description
stroke ol.style.Stroke

Stroke style.

setText(text) experimental

src/ol/style/textstyle.js, line 275

Set the text.

Name Type Description
text string | undefined

Text.

setTextAlign(textAlign) experimental

src/ol/style/textstyle.js, line 286

Set the text alignment.

Name Type Description
textAlign string | undefined

Text align.

setTextBaseline(textBaseline) experimental

src/ol/style/textstyle.js, line 297

Set the text baseline.

Name Type Description
textBaseline string | undefined

Text baseline.