KmlDataSource

new Cesium.KmlDataSource(options)

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 supported. 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.

参数名称 类型 描述信息
options KmlDataSource.ConstructorOptions 可选 Object describing initialization options
使用示例:
const viewer = new Cesium.Viewer('cesiumContainer');
viewer.dataSources.add(Cesium.KmlDataSource.load('../../SampleData/facilities.kmz',
     {
          camera: viewer.scene.camera,
          canvas: viewer.scene.canvas
     })
);
Demo:
参考:

成员(属性)

The position and orientation of this Camera will be used to populate various camera parameters when making network requests. Camera movement will determine when to trigger NetworkLink refresh if viewRefreshMode is onStop.

canvas : HTMLCanvasElement|undefined

The current size of this Canvas will be used to populate the Link parameters for client height and width.
Gets an event that will be raised when the underlying data changes.
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.
Gets or sets the clustering options for this data source. This object can be shared between multiple data sources.
Gets the credit that will be displayed for the data source
Gets the collection of Entity instances.
Gets an event that will be raised if an error is encountered during processing.
Gets a value indicating if the data source is currently loading data.
Gets the KML Tours that are used to guide the camera to specified destinations on given time intervals.
Gets an event that will be raised when the data source either starts or stops loading.
Gets or sets a human-readable name for this instance. This will be automatically be set to the KML document name on load.
Gets an event that will be raised when the data source refreshes a network link.
Gets whether or not this data source should be displayed.
Gets an event that will be raised when the data source finds an unsupported node type.

方法

static Cesium.KmlDataSource.load(data, options)Promise.<KmlDataSource>

Creates a Promise to a new instance loaded with the provided KML data.
参数名称 类型 描述信息
data Resource | string | Document | Blob A url, parsed KML document, or Blob containing binary KMZ data or a parsed KML document.
options KmlDataSource.ConstructorOptions 可选 An object specifying configuration options
返回值:
A promise that will resolve to a new KmlDataSource instance once the KML is loaded.
Cleans up any non-entity elements created by the data source. Currently this only affects ScreenOverlay elements.
Asynchronously loads the provided KML data, replacing any existing data.
参数名称 类型 描述信息
data Resource | string | Document | Blob A url, parsed KML document, or Blob containing binary KMZ data or a parsed KML document.
options KmlDataSource.LoadOptions 可选 An object specifying configuration options
返回值:
A promise that will resolve to this instances once the KML is loaded.
Updates any NetworkLink that require updating.
参数名称 类型 描述信息
time JulianDate The simulation time.
返回值:
True if this data source is ready to be displayed at the provided time, false otherwise.

定义的类型

Cesium.KmlDataSource.ConstructorOptions

Options for constructing a new KmlDataSource, or calling the static `load` method.
属性:
属性名称 类型 可选 默认值 描述信息
camera Camera <可选>
The camera that is used for viewRefreshModes and sending camera properties to network links.
canvas HTMLCanvasElement <可选>
The canvas that is used for sending viewer properties to network links.
credit Credit | string <可选>
A credit for the data source, which is displayed on the canvas.
sourceUri string <可选>
Overrides the url to use for resolving relative links and other KML network features.
clampToGround boolean <可选>
false true if we want the geometry features (Polygons, LineStrings and LinearRings) clamped to the ground.
ellipsoid Ellipsoid <可选>
Ellipsoid.WGS84 The global ellipsoid used for geographical calculations.
screenOverlayContainer Element | string <可选>
A container for ScreenOverlay images.

Cesium.KmlDataSource.LoadOptions

Initialization options for the `load` method.
属性:
属性名称 类型 可选 默认值 描述信息
sourceUri string <可选>
Overrides the url to use for resolving relative links and other KML network features.
clampToGround boolean <可选>
false true if we want the geometry features (Polygons, LineStrings and LinearRings) clamped to the ground.
ellipsoid Ellipsoid <可选>
Ellipsoid.WGS84 The global ellipsoid used for geographical calculations.
screenOverlayContainer Element | string <可选>
A container for ScreenOverlay images.