LabelCollection

external class LabelCollection(options: LabelCollection.ConstructorOptions? = definedExternally)(source)

A renderable collection of labels. Labels are viewport-aligned text positioned in the 3D scene. Each label can have a different font, color, scale, etc.

Labels are added and removed from the collection using LabelCollection.add and LabelCollection.remove.

// Create a label collection with two labels
const labels = scene.primitives.add(new LabelCollection());
labels.add({
position : new Cartesian3(1.0, 2.0, 3.0),
text : 'A label'
});
labels.add({
position : new Cartesian3(4.0, 5.0, 6.0),
text : 'Another label'
});

See also

Constructors

Link copied to clipboard
constructor(options: LabelCollection.ConstructorOptions? = definedExternally)

Types

Link copied to clipboard

Properties

Link copied to clipboard

The label blending option. The default is used for rendering both opaque and translucent labels. However, if either all of the labels are completely opaque or all are completely translucent, setting the technique to BlendOption.OPAQUE or BlendOption.TRANSLUCENT can improve performance by up to 2x.

Link copied to clipboard

This property is for debugging only; it is not for production use nor is it optimized.

Link copied to clipboard
var length: Int

Returns the number of labels in this collection. This is commonly used with LabelCollection.get to iterate over all the labels in the collection.

Link copied to clipboard

The 4x4 transformation matrix that transforms each label in this collection from model to world coordinates. When this is the identity matrix, the labels are drawn in world coordinates, i.e., Earth's WGS84 coordinates. Local reference frames can be used by providing a different transformation matrix, like that returned by Transforms.eastNorthUpToFixedFrame.

Link copied to clipboard

Determines if labels in this collection will be shown.

Functions

Link copied to clipboard
fun add(options: Label.ConstructorOptions? = definedExternally): Label

Creates and adds a label with the specified initial properties to the collection. The added label is returned so it can be modified or removed from the collection later.

Link copied to clipboard
fun contains(label: Label): Boolean

Check whether this collection contains a given label.

Link copied to clipboard
fun destroy()

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.

Link copied to clipboard
operator fun get(index: Int): Label

Returns the label in the collection at the specified index. Indices are zero-based and increase as labels are added. Removing a label shifts all labels after it to the left, changing their indices. This function is commonly used with LabelCollection.length to iterate over all the labels in the collection.

Link copied to clipboard

Returns true if this object was destroyed; otherwise, false.

Link copied to clipboard
fun remove(label: Label): Boolean

Removes a label from the collection. Once removed, a label is no longer usable.

Link copied to clipboard
fun removeAll()

Removes all labels from the collection.