原文链接及内容

实现效果:

示例代码如下:

本文定义的CZML数据的语法请参考:

  1. https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/CZML-Structure
  2. https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Packet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const viewer = new Cesium.Viewer("cesiumContainer");

const czml = [
{
id: "document",
version: "1.0",
},
{
id: "BatchedColors",
name: "BatchedColors",
tileset: {
uri: "../SampleData/Cesium3DTiles/Batched/BatchedColors/tileset.json",
},
},
];

const dataSourcePromise = viewer.dataSources.add(
Cesium.CzmlDataSource.load(czml),
);

dataSourcePromise
.then(function (dataSource) {
viewer.zoomTo(dataSource.entities.getById("BatchedColors"));
})
.catch(function (error) {
window.alert(error);
});