Class: Annotation

Annotation

Annotation controls the drawing and layout of features labels

Action and Events

Action Viewer Method Annotation Method Event
Update - update() annotation-update
Read annotation - -

Attributes

Attribute Type Description
font String A string describing the font [Default: 'monospace, plain, 12']. See Font for details.
color String A string describing the color [Default: undefined]. If the color is undefined, the legend color for the feature will be used. See Color for details.
onlyDrawFavorites Boolean Only draw labels for features that are favorited [Default: false]
labelPlacement String The label placement method for positioning labels. Choices: 'default', 'angled' [Default: 'default']
visible Boolean Labels are visible [Default: true]
meta Object Meta data for Annotation

Examples

// Only draw labels for features that have been marked as a favorite
cgv.annotation.update({
  onlyDrawFavorites: true
});

// Changing the label placement from the default to angled (for both fast and full draw)
cgv.annotation.labelPlacement = 'angled'

// Changing the label placement so that fast draw uses the default labels and full draw uses the angled labels
cgv.annotation.labelPlacementFast = 'default'
cgv.annotation.labelPlacementFull = 'angled'

new Annotation(viewer, options, meta)

Create the annotation.

Name Type Description
viewer Viewer

The viewer

options Object

Attributes used to create the annotation

meta Object optional

User-defined Meta data to add to the annotation.

Extends

Members

canvasCanvas

Get the canvas.

colorColor

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

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.

labelLineLengthNumber

Get or set the label line length.

labelPlacementLabelPlacement

Set the label placement instance for both fast and full drawing. Value can be one of the following: 'default', 'angled', or a custom LabelPlacement class.

labelPlacementFastLabelPlacement

Get or set the label placement instance for fast drawing. Values for setting can be one of the following: 'default', 'angled', or a custom LabelPlacement class.

labelPlacementFullLabelPlacement

Get or set the label placement instance for full drawing. Values for setting can be one of the following: 'default', 'angled', or a custom LabelPlacement class.

layoutLayout

Get the layout.

lengthNumber

The number of labels in the set.

metaBoolean

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

priorityMaxNumber

Get or set the number of priority labels that will be drawn for sure. If they overlap the label will be moved until they no longer overlap. Priority is defined as features that are marked as a "favorite". After favorites, features are sorted by size. For example, if priorityMax is 50 and there are 10 "favorite" features. The favorites will be drawn and then the 40 largest features will be drawn.

sequenceSequence

Get the sequence.

viewerViewer

Get the viewer.

visibleBoolean

Get or Set the visibility of this object.

Methods

addLabel(label)

Add a new label to the set.

Name Type Description
label Label

The Label to add to the set.

inherited deleteFromObjects()

Remove the object from Viewer.objects

invertColors()

Invert color

labels(term){CGArray}

Returns an CGArray of Labels or a single Label.

Name Type Description
term Integer | String | Array

See CGArray.get for details.

Returns:
Type Description
CGArray

removeLabels(labels)

Remove a label or an array of labels from the set.

Name Type Description
labels Label | Array

The Label(s) to remove from the set.

Returns JSON representing the object

toString(){String}

Return the class name as a string.

Returns:
Type Description
String
  • 'Annotation'

update(attributes)

Update annotation attributes. See updating records for details.

Name Type Description
attributes Object

Object describing the properties to change