add

fun add(options: Label.ConstructorOptions? = definedExternally): Label(source)

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.

// Example 1:  Add a label, specifying all the default values.
const l = labels.add({
show : true,
position : Cartesian3.ZERO,
text : '',
font : '30px sans-serif',
fillColor : Color.WHITE,
outlineColor : Color.BLACK,
outlineWidth : 1.0,
showBackground : false,
backgroundColor : new Color(0.165, 0.165, 0.165, 0.8),
backgroundPadding : new Cartesian2(7, 5),
style : LabelStyle.FILL,
pixelOffset : Cartesian2.ZERO,
eyeOffset : Cartesian3.ZERO,
horizontalOrigin : HorizontalOrigin.LEFT,
verticalOrigin : VerticalOrigin.BASELINE,
scale : 1.0,
translucencyByDistance : undefined,
pixelOffsetScaleByDistance : undefined,
heightReference : HeightReference.NONE,
distanceDisplayCondition : undefined
});
// Example 2:  Specify only the label's cartographic position,
// text, and font.
const l = labels.add({
position : Cartesian3.fromRadians(longitude, latitude, height),
text : 'Hello World',
font : '24px Helvetica',
});

Return

The label that was added to the collection.

Parameters

options

A template describing the label's properties as shown in Example 1.

See also