一次性加载
(method) DataSourceCollection.add(dataSource: Cesium.DataSource | Promise<Cesium.DataSource>): Promise<Cesium.DataSource>
const czml = [
{
id: "document",
name: "CZML Point",
version: "1.0",
clock: {
"interval": "2012-03-15T10:00:00Z/2012-03-15T18:00:00Z",
"currentTime": "2012-03-15T10:00:00Z",
"multiplier": 60,
"range": "LOOP_STOP",
"step": "SYSTEM_CLOCK_MULTIPLIER"
}
},
{
id: "point_1",
name: "point",
label: {
fillColor: {
rgba: [255, 255, 255, 255],
},
font: "13pt Lucida Console",
horizontalOrigin: "LEFT",
pixelOffset: {
cartesian2: [20, 0],
},
style: "FILL",
text: "referencing fillColor",
},
position: {
"interpolationAlgorithm": "LAGRANGE",
"interpolationDegree": 2,
"referenceFrame": "INERTIAL",
"epoch": "2012-03-15T10:00:00Z",
cartographicDegrees: [
0, .0, .0, 12742000,
2000, 20.0, .0, 12742000,
4000, 40.0, .0, 12742000,
6000, 60.0, .0, 12742000,
8000, 80.0, .0, 12742000,
10000, 100.0, .0, 12742000,
12000, 120.0, .0, 12742000,
14000, 140.0, .0, 12742000,
16000, 160.0, .0, 12742000,
18000, 180.0, .0, 12742000,
],
},
point: {
color: {
rgba: [255, 255, 255, 255],
},
pixelSize: 5,
},
path: {
"show": [
{
"interval": "2012-03-15T10:00:00Z/2012-03-15T15:00:00Z",
"boolean": true
}
],
"width": 1,
"material": {
"solidColor": {
"color": {
"rgba": [
255, 255, 255, 100
]
}
}
},
"resolution": 120,
leadTime: 0,
trailTime: 1e10
}
];
const dataSourcePromise = Cesium.CzmlDataSource.load(czml)
viewer.dataSources.add(dataSourcePromise)
dataSourcePromise.then((dataSource) => {
let point_1 = dataSource.entities.getById('point_1')
})
分段加载
可以通过CzmlDataSource.process
实现分段加载
(method) CzmlDataSource.process(czml: Resource | string | any, options?: CzmlDataSource.LoadOptions): Promise<CzmlDataSource>
//创建并添加dataSource
const dataSource = new Cesium.CzmlDataSource();
viewer.dataSources.add(dataSource);
//保留dataSource原有数据,合并新数据
dataSource.process(czmlPath/part1.url)
dataSource.process(czmlPath/part2.url)
其中,part1应含有czml信息和完整的entity信息,part2包含czml信息和entity位置信息(和properties信息),proerties信息通过vehicleEntity.properties.fuel_remaining.getValue()
方法获取,fuel_remaining
为properties
中的属性,定义为
"properties" : {
"fuel_remaining" : {
"epoch":"2012-08-04T16:00:00Z",
"number": [
3000, 19.9
]
}
},