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.
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
Billboard或者Label对象重叠检测,开启此项会动态计算、优先显示更靠近视角的billboard或者label,被遮挡的对象不予显示。
camera : Camera|undefined
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
.
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.
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.
clustering : EntityCluster
Gets or sets the clustering options for this data source. This object can be shared between multiple data sources.
credit : Credit
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.
重叠检测参数,Billboard或者Label类型对象包围盒的外延像素大小
Gets a value indicating if the data source is currently loading data.
kmlTours : Array.<KmlTour>
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.
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>
Creates a Promise to a new instance loaded with the provided KML data.
Name | Type | Description |
---|---|---|
data |
Resource | String | Document | 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:
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.
查询视口是否显示
Name | Type | Description |
---|---|---|
index |
Number | 视口索引号,最大值为8,索引号从下到上,左右往返排序 |
load(data, options) → Promise.<KmlDataSource>
Asynchronously loads the provided KML data, replacing any existing data.
Name | Type | Description |
---|---|---|
data |
Resource | String | Document | 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:
A promise that will resolve to this instances once the KML is loaded.
数据显示视口设置
Name | Type | Description |
---|---|---|
index |
Number | 视口索引号,最大值为8,索引号从下到上,左右往返排序 |
visible |
Boolean | 是否显示,默认值为true |
多视口显示设置,可设置该数据仅在指定的视口索引显示或隐藏,index可以为具体值也可为数组,当index为undefined时,该数据在所有窗口显示或隐藏
Name | Type | Description |
---|---|---|
index |
Number | Array | 视口的索引值 |
visible |
Boolean | 显示/隐藏,默认为ture |
Example:
obj.setVisibleAtViewportOnly([0,2,4], false);//设置对象仅在0,2,4视口隐藏,其他窗口显示
obj.setVisibleAtViewportOnly([0,1,2,6], true);//设置对象仅在0,1,2,6视口显示,其他窗口隐藏
obj.setVisibleAtViewportOnly(undefined, true);//设置对象仅在所有视口都显示
Updates any NetworkLink that require updating.
Name | Type | Description |
---|---|---|
time |
JulianDate | The simulation time. |
Returns:
True if this data source is ready to be displayed at the provided time, false otherwise.
Type Definitions
Options for constructing a new KmlDataSource, or calling the static `load` method.
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
camera |
Camera |
<optional> |
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> |
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. |
ellipsoid |
Ellipsoid |
<optional> |
Ellipsoid.WGS84 | The global ellipsoid used for geographical calculations. |
screenOverlayContainer |
Element | String |
<optional> |
A container for ScreenOverlay images. |
Initialization options for the `load` method.
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
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. |
ellipsoid |
Ellipsoid |
<optional> |
Ellipsoid.WGS84 | The global ellipsoid used for geographical calculations. |
screenOverlayContainer |
Element | String |
<optional> |
A container for ScreenOverlay images. | |
options.avoidSelfOverlap |
Boolean |
<optional> |
false | Billboard或者Label对象重叠检测,开启此项会动态计算、优先显示更靠近视角的billboard或者label,被遮挡的对象不予显示. |
options.interval |
Number |
<optional> |
1.0 | 重叠检测参数,Billboard或者Label类型对象包围盒的外延像素大小. |