Class: PolylineCollection

PolylineCollection

new PolylineCollection(optionsopt)

A renderable collection of polylines.


Example polylines


Polylines are added and removed from the collection using PolylineCollection#add and PolylineCollection#remove.
Parameters:
Name Type Attributes Description
options Object <optional>
Object with the following properties:
Properties
Name Type Attributes Default Description
modelMatrix Matrix4 <optional>
Matrix4.IDENTITY The 4x4 transformation matrix that transforms each polyline from model to world coordinates.
debugShowBoundingVolume Boolean <optional>
false For debugging only. Determines if this primitive's commands' bounding spheres are shown.
Source:
See:
Example
// Create a polyline collection with two polylines
var polylines = new Cesium.PolylineCollection();
polylines.add({
  positions : Cesium.Cartesian3.fromDegreesArray([
    -75.10, 39.57,
    -77.02, 38.53,
    -80.50, 35.14,
    -80.12, 25.46]),
  width : 2
});

polylines.add({
  positions : Cesium.Cartesian3.fromDegreesArray([
    -73.10, 37.57,
    -75.02, 36.53,
    -78.50, 33.14,
    -78.12, 23.46]),
  width : 4
});

Members

debugShowBoundingVolume :Boolean

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

Draws the bounding sphere for each draw command in the primitive.

Type:
  • Boolean
Default Value:
  • false
Source:

length :Number

Returns the number of polylines in this collection. This is commonly used with PolylineCollection#get to iterate over all the polylines in the collection.
Type:
  • Number
Source:

modelMatrix :Matrix4

The 4x4 transformation matrix that transforms each polyline in this collection from model to world coordinates. When this is the identity matrix, the polylines 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.
Type:
Default Value:
Source:

Methods

add(polylineopt) → {Polyline}

Creates and adds a polyline with the specified initial properties to the collection. The added polyline is returned so it can be modified or removed from the collection later.
Parameters:
Name Type Attributes Description
polyline Object <optional>
A template describing the polyline's properties as shown in Example 1.
Source:
See:
Throws:
This object was destroyed, i.e., destroy() was called.
Type
DeveloperError
Returns:
The polyline that was added to the collection.
Type
Polyline
Example
// Example 1:  Add a polyline, specifying all the default values.
var p = polylines.add({
  show : true,
  positions : ellipsoid.cartographicArrayToCartesianArray([
           Cesium.Cartographic.fromDegrees(-75.10, 39.57),
           Cesium.Cartographic.fromDegrees(-77.02, 38.53)]),
  width : 1
});

contains(polyline) → {Boolean}

Determines if this collection contains the specified polyline.
Parameters:
Name Type Description
polyline Polyline The polyline to check for.
Source:
See:
Returns:
true if this collection contains the polyline, false otherwise.
Type
Boolean

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.
Source:
See:
Throws:
This object was destroyed, i.e., destroy() was called.
Type
DeveloperError
Returns:
Type
undefined
Example
polylines = polylines && polylines.destroy();

get(index) → {Polyline}

Returns the polyline in the collection at the specified index. Indices are zero-based and increase as polylines are added. Removing a polyline shifts all polylines after it to the left, changing their indices. This function is commonly used with PolylineCollection#length to iterate over all the polylines in the collection.
Parameters:
Name Type Description
index Number The zero-based index of the polyline.
Source:
See:
Throws:
This object was destroyed, i.e., destroy() was called.
Type
DeveloperError
Returns:
The polyline at the specified index.
Type
Polyline
Example
// Toggle the show property of every polyline in the collection
var len = polylines.length;
for (var i = 0; i < len; ++i) {
  var p = polylines.get(i);
  p.show = !p.show;
}

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.
Source:
See:
Returns:
true if this object was destroyed; otherwise, false.
Type
Boolean

remove(polyline) → {Boolean}

Removes a polyline from the collection.
Parameters:
Name Type Description
polyline Polyline The polyline to remove.
Source:
See:
Throws:
This object was destroyed, i.e., destroy() was called.
Type
DeveloperError
Returns:
true if the polyline was removed; false if the polyline was not found in the collection.
Type
Boolean
Example
var p = polylines.add(...);
polylines.remove(p);  // Returns true

removeAll()

Removes all polylines from the collection.
Source:
See:
Throws:
This object was destroyed, i.e., destroy() was called.
Type
DeveloperError
Example
polylines.add(...);
polylines.add(...);
polylines.removeAll();

update()

Called when Viewer or CesiumWidget render the scene to get the draw commands needed to render this primitive.

Do not call this function directly. This is documented just to list the exceptions that may be propagated when the scene is rendered:

Source:
Throws:
Vertex texture fetch support is required to render primitives with per-instance attributes. The maximum number of vertex texture image units must be greater than zero.
Type
RuntimeError