A
DataSource 它处理 Keyhole 标记语言 2.2 (KML)。 which processes Keyhole Markup Language 2.2 (KML).
Cesium中的KML支持并不完整,但是大量的标准,以及Google的 KML support in Cesium is incomplete, but a large amount of the standard, as well as Google's gx 支持扩展命名空间。请参阅 Github 问题 extension namespace, is supported. See Github issue
#873 了解支持和不支持的内容的详细列表。当遇到大多数不支持的功能时,Cesium也会将信息写入控制台。 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.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
options |
KmlDataSource.ConstructorOptions | 可选 optional 描述初始化选项的对象 Object describing initialization options |
示例: Example:
const viewer = new Cesium.Viewer('cesiumContainer');
viewer.dataSources.add(Cesium.KmlDataSource.load('../../SampleData/facilities.kmz',
{
camera: viewer.scene.camera,
canvas: viewer.scene.canvas
})
);
演示: Demo:
另见: See:
成员 Members
camera : Camera|undefined
这个位置和方向 The position and orientation of this
Camera 将用于在发出网络请求时填充各种相机参数。相机移动将决定何时触发 NetworkLink 刷新,如果 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.
该画布的当前大小将用于填充客户端高度和宽度的链接参数。 The current size of this Canvas will be used to populate the Link parameters for client height and width.
changedEvent : Event
获取当基础数据更改时将引发的事件。 Gets an event that will be raised when the underlying data changes.
获取由加载的 KML 定义的时钟设置。这表示所有时间动态数据的总可用性间隔。如果 KML 不包含时间动态数据,则该值未定义。 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.
errorEvent : Event
获取在处理过程中遇到错误时将引发的事件。 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.
kmlTours : Array.<KmlTour>
获取用于在给定时间间隔引导相机到达指定目的地的 KML 游览。 Gets the KML Tours that are used to guide the camera to specified destinations on given time intervals.
loadingEvent : Event
获取当数据源开始或停止加载时将引发的事件。 Gets an event that will be raised when the data source either starts or stops loading.
获取或设置此实例的人类可读名称。这将在加载时自动设置为 KML 文档名称。 Gets or sets a human-readable name for this instance. This will be automatically be set to the KML document name on load.
refreshEvent : Event
获取数据源刷新网络链接时将引发的事件。 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.
unsupportedNodeEvent : Event
获取当数据源发现不支持的节点类型时将引发的事件。 Gets an event that will be raised when the data source finds an unsupported node type.
方法 Methods
static Cesium.KmlDataSource.load(data, options) → Promise.<KmlDataSource>
创建一个 Promise 到加载了所提供的 KML 数据的新实例。 Creates a Promise to a new instance loaded with the provided KML data.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
data |
Resource | string | Document | Blob | url、已解析的 KML 文档或包含二进制 KMZ 数据或已解析的 KML 文档的 Blob。 A url, parsed KML document, or Blob containing binary KMZ data or a parsed KML document. |
options |
KmlDataSource.ConstructorOptions | 可选 optional 指定配置选项的对象 An object specifying configuration options |
返回: Returns:
加载 KML 后将解析为新的 KmlDataSource 实例的承诺。 A promise that will resolve to a new KmlDataSource instance once the KML is loaded.
清除数据源创建的所有非实体元素。目前这仅影响 ScreenOverlay 元素。 Cleans up any non-entity elements created by the data source. Currently this only affects ScreenOverlay elements.
load(data, options) → Promise.<KmlDataSource>
异步加载提供的 KML 数据,替换任何现有数据。 Asynchronously loads the provided KML data, replacing any existing data.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
data |
Resource | string | Document | Blob | url、已解析的 KML 文档或包含二进制 KMZ 数据或已解析的 KML 文档的 Blob。 A url, parsed KML document, or Blob containing binary KMZ data or a parsed KML document. |
options |
KmlDataSource.LoadOptions | 可选 optional 指定配置选项的对象 An object specifying configuration options |
返回: Returns:
加载 KML 后将解析此实例的承诺。 A promise that will resolve to this instances once the KML is loaded.
更新任何需要更新的 NetworkLink。 Updates any NetworkLink that require updating.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
time |
JulianDate | 模拟时间。 The simulation time. |
返回: Returns:
如果此数据源已准备好在提供的时间显示,则为 true,否则为 false。 True if this data source is ready to be displayed at the provided time, false otherwise.
类型定义 Type Definitions
用于构造新 KmlDataSource 或调用静态“load”方法的选项。 Options for constructing a new KmlDataSource, or calling the static `load` method.
属性: Properties:
| 名称 Name | 类型 Type | Attributes | 默认值 Default | 说明 Description |
|---|---|---|---|---|
camera |
Camera |
<可选> <optional> |
用于 viewRefreshModes 并将相机属性发送到网络链接的相机。 The camera that is used for viewRefreshModes and sending camera properties to network links. | |
canvas |
HTMLCanvasElement |
<可选> <optional> |
用于将查看器属性发送到网络链接的画布。 The canvas that is used for sending viewer properties to network links. | |
credit |
Credit | string |
<可选> <optional> |
数据源的来源,显示在画布上。 A credit for the data source, which is displayed on the canvas. | |
sourceUri |
string |
<可选> <optional> |
覆盖用于解析相对链接和其他 KML 网络功能的 url。 Overrides the url to use for resolving relative links and other KML network features. | |
clampToGround |
boolean |
<可选> <optional> |
false | 如果我们希望将几何特征(多边形、线串和线性环)固定在地面上,则为 true。 true if we want the geometry features (Polygons, LineStrings and LinearRings) clamped to the ground. |
ellipsoid |
Ellipsoid |
<可选> <optional> |
Ellipsoid.default | 用于地理计算的全球椭球体。 The global ellipsoid used for geographical calculations. |
screenOverlayContainer |
Element | string |
<可选> <optional> |
ScreenOverlay 图像的容器。 A container for ScreenOverlay images. |
“load”方法的初始化选项。 Initialization options for the `load` method.
属性: Properties:
| 名称 Name | 类型 Type | Attributes | 默认值 Default | 说明 Description |
|---|---|---|---|---|
sourceUri |
string |
<可选> <optional> |
覆盖用于解析相对链接和其他 KML 网络功能的 url。 Overrides the url to use for resolving relative links and other KML network features. | |
clampToGround |
boolean |
<可选> <optional> |
false | 如果我们希望将几何特征(多边形、线串和线性环)固定在地面上,则为 true。 true if we want the geometry features (Polygons, LineStrings and LinearRings) clamped to the ground. |
ellipsoid |
Ellipsoid |
<可选> <optional> |
Ellipsoid.default | 用于地理计算的全球椭球体。 The global ellipsoid used for geographical calculations. |
screenOverlayContainer |
Element | string |
<可选> <optional> |
ScreenOverlay 图像的容器。 A container for ScreenOverlay images. |
