Czml Reference Properties
Runnable Cesium example: Czml Reference Properties. 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 属性引用
说明:位置与颜色都写成 reference,改被引用对象一处,引用方一起变
核心逻辑:position.reference 指 id#position,label.outlineColor.reference 指 id#label.outlineColor
依赖: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, 60, 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 = 1;
viewer.clock.shouldAnimate = true;
var data = [
{
id: 'document',
name: '引用属性',
version: '1.0',
clock: {
interval: '2026-10-28T00:00:00Z/2026-10-28T00:01:00Z',
currentTime: '2026-10-28T00:00:00Z',
multiplier: 1,
range: 'LOOP_STOP'
}
},
{
id: 'anchor',
name: '被引用的锚点',
availability: '2026-10-28T00:00:00Z/2026-10-28T00:01:00Z',
position: {
epoch: '2026-10-28T00:00:00Z',
interpolationAlgorithm: 'LINEAR',
interpolationDegree: 1,
cartographicDegrees: [
0, 116.360, 39.900, 400,
30, 116.392, 39.918, 900,
60, 116.360, 39.900, 400
]
},
point: {
pixelSize: 12,
color: { rgba: [255, 214, 102, 255] },
outlineColor: { rgba: [255, 255, 255, 255] },
outlineWidth: 2,
disableDepthTestDistance: Number.POSITIVE_INFINITY
},
label: {
text: 'anchor',
font: '500 13px "Microsoft YaHei", sans-serif',
fillColor: { rgba: [255, 255, 255, 255] },
outlineColor: { rgba: [255, 214, 102, 255] },
outlineWidth: 3,
style: 'FILL_AND_OUTLINE',
pixelOffset: { cartesian2: [18, 0] },
horizontalOrigin: 'LEFT',
disableDepthTestDistance: Number.POSITIVE_INFINITY
}
},
{
id: 'follow',
name: '位置引用 anchor',
availability: '2026-10-28T00:00:00Z/2026-10-28T00:01:00Z',
position: { reference: 'anchor#position' },
label: {
text: 'position 引用 anchor',
font: '500 13px "Microsoft YaHei", sans-serif',
fillColor: { rgba: [255, 255, 255, 255] },
outlineColor: { reference: 'anchor#label.outlineColor' },
outlineWidth: 3,
style: 'FILL_AND_OUTLINE',
pixelOffset: { cartesian2: [0, -26] },
disableDepthTestDistance: Number.POSITIVE_INFINITY
}
},
{
id: 'color-ref',
name: '填充色引用 anchor 的描边色',
availability: '2026-10-28T00:00:00Z/2026-10-28T00:01:00Z',
position: { cartographicDegrees: [116.428, 39.902, 0] },
polygon: {
positions: {
cartographicDegrees: [
116.404, 39.884, 0,
116.452, 39.886, 0,
116.452, 39.922, 0,
116.404, 39.920, 0
]
},
height: 0,
material: {
solidColor: { color: { reference: 'anchor#label.outlineColor' } }
},
outline: true,
outlineColor: { rgba: [240, 240, 240, 200] }
}
},
{
id: 'caption',
position: { cartographicDegrees: [116.392, 39.874, 0] },
label: {
text: '锚点一动,引用它的位置与颜色一起动',
font: '500 13px "Microsoft YaHei", sans-serif',
fillColor: { rgba: [216, 230, 246, 255] },
disableDepthTestDistance: Number.POSITIVE_INFINITY
}
}
];
Cesium.CzmlDataSource.load(data).then(function (ds) {
viewer.dataSources.add(ds);
});
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(116.392, 39.858, 16000),
orientation: {
heading: 0,
pitch: Cesium.Math.toRadians(-44),
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.