Class: SimpleLabel

cercaliagl.SimpleLabel


Javascript ES5

const simpleLabel = new cercaliagl.SimpleLabel({ ... });

Create a marker text. This text is rendered on <canvas/> via webgl. It is not possible to edit via CSS classes.

Example usage:

const simpleLabel = new cercaliagl.SimpleLabe({
  text: '
});

new SimpleLabel(options)

Name Type Description
options

Options

Name Type Description
fontSize number

Text size, in pixels. Default 13.

offset Array.<number>

Simpel Label offset, units in ems. Defaults to [0, 0].

anchor string

Anchor. Possible values: center, left, right, top, bottom, top-left, top-right, bottom-left, bottom-right. Defaults top

justify string

Justify: Possible values: auto, left, center, right. Defaults center

text string

Simple Label text (with no background).

visible boolean

Visible. Show or hide text.

textColor string

Text color. Default #000000.

textOpacity string

Text opacity. Default 1.

strokeColor string

Stroke color. Default #ffffff.

strokeWidth number

Stroke width. Default 2.

textRotation number

Text rotation. Default 0.

Methods

getAnchor(){string}

Get simple label anchor

Returns:
Anchor

getFontSize(){number}

Returns text font

Returns:
Font size in pixels.

getJustify(){string}

Get simple label justify

Returns:
Justify

getOffset(){Array.<number>}

Returns offset.

Returns:
Offset [x,y].

getStrokeColor(){string}

Get simple label stroke color

Returns:
strokeColor

getStrokeWidth(){number}

Get simple label stroke width

Returns:
strokeWidth

getText(ignoreVisibility){string}

Get simple label text

Name Type Description
ignoreVisibility boolean (defaults to false)

Ignore visibility

Returns:
Text.

getTextColor(){string}

Get simple label color

Returns:
Color

getTextOpacity(){number}

Get simple label text opacity

Returns:
Text opacity

getTextRotation(){number}

Get simple label text rotation

Returns:
Text rotation

isVisible(){boolean}

Return if simple label is visible

setFontSize(fontSize)

Change the text size in pixels. If have an assigned marker updates it

Name Type Description
fontSize number

Font size in pixels.

setOffset(offset)

Change displacement on the horizontal axis. If have an assigned marker updates it

Name Type Description
offset Array.<number>

Offset [x,y].

setText(text)

Change the text passed by parameter. If have an assigned marker updates it

Name Type Description
text string

Text to put to simple label.

setTextOpacity(textOpacity)

Change simple label opacity. If have an assigned marker updates it

Name Type Description
textOpacity number

Text opacity

setVisible(visible)

Show or hide simple label text

Name Type Description
visible boolean

Visible