Class: KmlDataSource

KmlDataSource

new KmlDataSource()

A DataSource which processes Keyhole Markup Language 2.2 (KML).

KML support in Cesium is incomplete, but a large amount of the standard, as well as Google's gx extension namespace, is supported. See Github issue #873 for a detailed list of what is and isn't support. Cesium will also write information to the console when it encounters most unsupported features.

Non visual feature data, such as atom:author and ExtendedData is exposed via an instance of KmlFeatureData, which is added to each Entity under the kml property.

Parameters:
Name Type Attributes Description
options.camera Camera The camera that is used for viewRefreshModes and sending camera properties to network links.
options.canvas Canvas The canvas that is used for sending viewer properties to network links.
options.proxy DefaultProxy <optional>
A proxy to be used for loading external data.
Source:
See:
Example
var viewer = new Cesium.Viewer('cesiumContainer');
viewer.dataSources.add(Cesium.KmlDataSource.load('../../SampleData/facilities.kmz'),
     {
         camera: viewer.scene.camera,
         canvas: viewer.scene.canvas
     });

Members

changedEvent :Event

Gets an event that will be raised when the underlying data changes.
Type:
Source:

clock :DataSourceClock

Gets the clock settings defined by the loaded KML. This represents the total availability interval for all time-dynamic data. If the KML does not contain time-dynamic data, this value is undefined.
Type:
Source:

clustering :EntityCluster

Gets or sets the clustering options for this data source. This object can be shared between multiple data sources.
Type:
Source:

entities :EntityCollection

Gets the collection of Entity instances.
Type:
Source:

errorEvent :Event

Gets an event that will be raised if an error is encountered during processing.
Type:
Source:

isLoading :Boolean

Gets a value indicating if the data source is currently loading data.
Type:
  • Boolean
Source:

loadingEvent :Event

Gets an event that will be raised when the data source either starts or stops loading.
Type:
Source:

name :String

Gets a human-readable name for this instance. This will be automatically be set to the KML document name on load.
Type:
  • String
Source:

refreshEvent :Event

Gets an event that will be raised when the data source refreshes a network link.
Type:
Source:

show :Boolean

Gets whether or not this data source should be displayed.
Type:
  • Boolean
Source:

unsupportedNodeEvent :Event

Gets an event that will be raised when the data source finds an unsupported node type.
Type:
Source:

Methods

(static) load(data, optionsopt) → {Promise.<KmlDataSource>}

Creates a Promise to a new instance loaded with the provided KML data.
Parameters:
Name Type Attributes Description
data String | Document | Blob A url, parsed KML document, or Blob containing binary KMZ data or a parsed KML document.
options Object <optional>
An object with the following properties:
Properties
Name Type Attributes Default Description
camera Camera The camera that is used for viewRefreshModes and sending camera properties to network links.
canvas Canvas The canvas that is used for sending viewer properties to network links.
proxy DefaultProxy <optional>
A proxy to be used for loading external data.
sourceUri String <optional>
Overrides the url to use for resolving relative links and other KML network features.
clampToGround Boolean <optional>
false true if we want the geometry features (Polygons, LineStrings and LinearRings) clamped to the ground. If true, lines will use corridors so use Entity.corridor instead of Entity.polyline.
Source:
Returns:
A promise that will resolve to a new KmlDataSource instance once the KML is loaded.
Type
Promise.<KmlDataSource>

load(data, optionsopt) → {Promise.<KmlDataSource>}

Asynchronously loads the provided KML data, replacing any existing data.
Parameters:
Name Type Attributes Description
data String | Document | Blob A url, parsed KML document, or Blob containing binary KMZ data or a parsed KML document.
options Object <optional>
An object with the following properties:
Properties
Name Type Attributes Default Description
sourceUri Number <optional>
Overrides the url to use for resolving relative links and other KML network features.
clampToGround Boolean <optional>
false true if we want the geometry features (Polygons, LineStrings and LinearRings) clamped to the ground. If true, lines will use corridors so use Entity.corridor instead of Entity.polyline.
Source:
Returns:
A promise that will resolve to this instances once the KML is loaded.
Type
Promise.<KmlDataSource>

update(time) → {Boolean}

Updates any NetworkLink that require updating
Parameters:
Name Type Description
time JulianDate The simulation time.
Source:
Returns:
True if this data source is ready to be displayed at the provided time, false otherwise.
Type
Boolean