Czml Path
Runnable Cesium example: Czml Path. Open the live demo, read the complete source, and copy the file into your project. No build step or API key.
single HTML file · CDN dependencies onlyinterface may contain Chinese labels
Source
<!--
示例:CZML 的 path 自动画出运动轨迹
说明:对象沿五个城市移动,path 把走过的位置连成线,trailTime 决定尾巴长度
核心逻辑:clock 推进时间 → position 按采样插值 → path 采样生成轨迹
依赖:CesiumJS 1.121 · jsDelivr CDN
-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta name="robots" content="noindex,follow">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CZML 运动路径</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/cesium@1.121.0/Build/Cesium/Widgets/widgets.css">
<style>
html,body{height:100%;margin:0}
body{background:#0e1116;color:#e6e8ec;overflow:hidden;
font:13px/1.6 -apple-system,"Segoe UI","PingFang SC",sans-serif}
#c{height:100%}
.cesium-viewer-bottom .cesium-widget-credits,.cesium-viewer-animationContainer,
.cesium-viewer-timelineContainer{display:none!important}
</style>
</head>
<body>
<div id="c"></div>
<script src="https://cdn.jsdelivr.net/npm/cesium@1.121.0/Build/Cesium/Cesium.js"></script>
<script>
(function () {
'use strict';
var viewer = new Cesium.Viewer('c', {
baseLayer: false,
baseLayerPicker: false, geocoder: false, homeButton: false,
sceneModePicker: false, navigationHelpButton: false,
animation: false, timeline: false, fullscreenButton: false,
infoBox: false, selectionIndicator: false
});
var scene = viewer.scene;
scene.globe.baseColor = Cesium.Color.fromCssColorString('#1c2733');
scene.backgroundColor = Cesium.Color.fromCssColorString('#0e1116');
scene.skyBox.show = false;
scene.moon.show = false;
if (scene.skyAtmosphere) scene.skyAtmosphere.show = false;
var start = Cesium.JulianDate.fromIso8601('2026-10-28T00:00:00Z');
var stop = Cesium.JulianDate.addSeconds(start, 300, new Cesium.JulianDate());
viewer.clock.startTime = start.clone();
viewer.clock.stopTime = stop.clone();
viewer.clock.currentTime = start.clone();
viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
viewer.clock.multiplier = 6;
viewer.clock.shouldAnimate = true;
var data = [
{
id: 'document',
name: '运动路径',
version: '1.0',
clock: {
interval: '2026-10-28T00:00:00Z/2026-10-28T00:05:00Z',
currentTime: '2026-10-28T00:00:00Z',
multiplier: 6,
range: 'LOOP_STOP',
step: 'SYSTEM_CLOCK_MULTIPLIER'
}
},
{
id: 'flight',
name: '航线',
availability: '2026-10-28T00:00:00Z/2026-10-28T00:05:00Z',
position: {
epoch: '2026-10-28T00:00:00Z',
interpolationAlgorithm: 'LINEAR',
interpolationDegree: 1,
cartographicDegrees: [
0, 116.39, 39.90, 160000,
60, 121.47, 31.23, 160000,
120, 113.26, 23.12, 160000,
180, 104.06, 30.57, 160000,
240, 108.95, 34.34, 160000,
300, 116.39, 39.90, 160000
]
},
point: {
pixelSize: 10,
color: { rgba: [255, 214, 102, 255] },
outlineColor: { rgba: [20, 24, 30, 255] },
outlineWidth: 2,
disableDepthTestDistance: Number.POSITIVE_INFINITY
},
path: {
resolution: 1,
leadTime: 0,
trailTime: 120,
width: 3,
material: { polylineGlow: { color: { rgba: [255, 196, 80, 255] }, glowPower: 0.2 } }
},
label: {
text: 'trailTime = 120 秒',
font: '500 12px "Microsoft YaHei", sans-serif',
fillColor: { rgba: [255, 236, 200, 255] },
pixelOffset: { cartesian2: [0, -20] },
disableDepthTestDistance: Number.POSITIVE_INFINITY
}
}
];
Cesium.CzmlDataSource.load(data).then(function (ds) {
viewer.dataSources.add(ds);
});
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(112, 30, 8400000),
orientation: {
heading: 0,
pitch: Cesium.Math.toRadians(-52),
roll: 0
},
duration: 0
});
})();
</script>
</body>
</html>
Language: the code and this page are in English; the full tutorial and API notes for this example are in Chinese. The demo itself is the authoritative version — it runs exactly as shown.