LabelCollection 您所在的位置:网站首页 labelcollection LabelCollection

LabelCollection

2024-07-01 13:42| 来源: 网络整理| 查看: 265

add(options) → 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. Performance:

Calling add is expected constant time. However, the collection's vertex buffer is rewritten; this operations is O(n) and also incurs CPU to GPU overhead. For best performance, add as many billboards as possible before calling update.

Name Type Description options Object optional A template describing the label's properties as shown in Example 1. Returns: The label that was added to the collection. Throws: DeveloperError : This object was destroyed, i.e., destroy() was called. Examples: // Example 1: Add a label, specifying all the default values. var l = labels.add({ show : true, position : Cesium.Cartesian3.ZERO, text : '', font : '30px sans-serif', fillColor : Cesium.Color.WHITE, outlineColor : Cesium.Color.BLACK, style : Cesium.LabelStyle.FILL, pixelOffset : Cesium.Cartesian2.ZERO, eyeOffset : Cesium.Cartesian3.ZERO, horizontalOrigin : Cesium.HorizontalOrigin.LEFT, verticalOrigin : Cesium.VerticalOrigin.BOTTOM, scale : 1.0 }); // Example 2: Specify only the label's cartographic position, // text, and font. var l = labels.add({ position : Cartesian3.fromRadians(longitude, latitude, height), text : 'Hello World', font : '24px Helvetica', }); See: LabelCollection#remove LabelCollection#removeAll Source: Scene/LabelCollection.js, line 427 contains(label) → Boolean Check whether this collection contains a given label. Name Type Description label Label The label to check for. Returns: true if this collection contains the label, false otherwise. See: LabelCollection#get Source: Scene/LabelCollection.js, line 504 destroy() → undefined 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. Once an object is destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example. Returns: Throws: DeveloperError : This object was destroyed, i.e., destroy() was called. Example: labels = labels && labels.destroy(); See: LabelCollection#isDestroyed Source: Scene/LabelCollection.js, line 632 get(index) → 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. Performance:

Expected constant time. If labels were removed from the collection and Scene#render was not called, an implicit O(n) operation is performed.

Name Type Description index Number The zero-based index of the billboard. Returns: The label at the specified index. Throws: DeveloperError : This object was destroyed, i.e., destroy() was called. Example: // Toggle the show property of every label in the collection var len = labels.length; for (var i = 0; i < len; ++i) { var l = billboards.get(i); l.show = !l.show; } See: LabelCollection#length Source: Scene/LabelCollection.js, line 535 isDestroyed() → Boolean Returns true if this object was destroyed; otherwise, false. If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception. Returns: True if this object was destroyed; otherwise, false. See: LabelCollection#destroy Source: Scene/LabelCollection.js, line 611 remove(label) → Boolean Removes a label from the collection. Once removed, a label is no longer usable. Performance:

Calling remove is expected constant time. However, the collection's vertex buffer is rewritten - an O(n) operation that also incurs CPU to GPU overhead. For best performance, remove as many labels as possible before calling update. If you intend to temporarily hide a label, it is usually more efficient to call Label#show instead of removing and re-adding the label.

Name Type Description label Label The label to remove. Returns: true if the label was removed; false if the label was not found in the collection. Throws: DeveloperError : This object was destroyed, i.e., destroy() was called. Example: var l = labels.add(...); labels.remove(l); // Returns true See: LabelCollection#add LabelCollection#removeAll Label#show Source: Scene/LabelCollection.js, line 458 removeAll() Removes all labels from the collection. Performance:

O(n). It is more efficient to remove all the labels from a collection and then add new ones than to create a new collection entirely.

Throws: DeveloperError : This object was destroyed, i.e., destroy() was called. Example: labels.add(...); labels.add(...); labels.removeAll(); See: LabelCollection#add LabelCollection#remove Source: Scene/LabelCollection.js, line 486


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有