Class: Caption

Caption

Captions are used to add additional annotation to the map.

Action and Events

Action Viewer Method Caption Method Event
Add addCaptions() - captions-add
Update updateCaptions() update() captions-update
Remove removeCaptions() remove() captions-remove
Reorder moveCaption() move() captions-reorder
Read captions() - -

Attributes

Attribute Type Description
name String Text of the caption
position String|Object Where to draw the caption [Default: 'middle-center']. See Position for details.
anchor String|Object Where to anchor the caption box to the position [Default: 'middle-center']. See Anchor for details.
font String A string describing the font [Default: 'SansSerif, plain, 8']. See Font for details.
fontColor String A string describing the color [Default: 'black']. See Color for details.
textAlignment String Alignment of caption text: left, center, or right [Default: 'left']
backgroundColor String A string describing the background color of the caption [Default: 'white']. See Color for details.
onic String Place the caption relative to the 'canvas' or 'map' [Default: 'canvas']
visible Boolean Caption is visible [Default: true]
meta Object Meta data for Caption

ic Ignored on Caption creation

Examples

new Caption(viewer, options, meta)

Create a new Caption.

Name Type Description
viewer Viewer

The viewer.

options Object

Attributes used to create the caption.

meta Object optional

User-defined Meta data to add to the caption.

Extends

Members

anchorString

Get or set the caption anchor position.

backgroundColorColor

Get or set the backgroundColor. When setting the color, a string representing the color or a Color object can be used. For details see Color.

canvasCanvas

Get the canvas.

fontFont

Get or set the font. When setting the font, a string representing the font or a Font object can be used. For details see Font.

fontColorColor

Get or set the fontColor. When setting the color, a string representing the color or a Color object can be used. For details see Color.

layoutLayout

Get the layout.

metaBoolean

Get or Set the meta data of this object. See the meta data tutorial for details.

nameString

Get or set the text shown for this caption.

onString

Get or set where the caption will be relative to. Values: 'map', 'canvas'

onCanvasBoolean

Returns true if the caption is positioned on the canvas

onMapBoolean

Returns true if the caption is positioned on the map

positionString

Get or set the caption position.

sequenceSequence

Get the sequence.

textAlignmentString

Get or set the text alignment. Possible values are left, center, or right.

viewerViewer

Get or set the Viewer

visibleBoolean

Get or Set the visibility of this object.

Methods

clear()

Clear the box containing this caption.

inherited deleteFromObjects()

Remove the object from Viewer.objects

Draw the caption

highlight(color)

Highlight the caption by drawing a box around it.

Name Type Description
color Color

Color of the highlighting outline

invertColors()

Invert the colors of the caption (i.e. backgroundColor and fontColor).

move(newIndex)

Move this caption to a new index in the array of Viewer captions.

Name Type Description
newIndex Number

New index for this caption (0-based)

moveTo(duration)

Move the map to center the caption. Only works with caption positioned on the map (not the canvas).

Name Type Default Description
duration Number 1000

Duration of move animation

remove()

Remove caption

toJSON()

Returns JSON representing the object

toString(){String}

Return the class name as a string.

Returns:
Type Description
String
  • 'Caption'

update(attributes)

Update caption attributes. See updating records for details.

Name Type Description
attributes Object

Object describing the properties to change