Czml Wall
Runnable Cesium example: Czml Wall. 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 沿折线拉起墙体
说明:minimumHeights 与 maximumHeights 的长度要和 positions 的顶点数一致
核心逻辑:wall.positions + 两组高度 → material 半透明 → CzmlDataSource.load
依赖: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 positions = [
116.344, 39.884, 0,
116.372, 39.906, 0,
116.404, 39.918, 0,
116.442, 39.906, 0,
116.452, 39.884, 0
];
var tops = [900, 1600, 2400, 1500, 800];
var bottoms = [0, 200, 400, 200, 0];
var data = [
{ id: 'document', name: '墙体', version: '1.0' },
{
id: 'wall',
name: '边界墙',
wall: {
positions: { cartographicDegrees: positions },
maximumHeights: tops,
minimumHeights: bottoms,
material: { solidColor: { color: { rgba: [77, 155, 255, 120] } } },
outline: true,
outlineColor: { rgba: [200, 226, 255, 200] }
}
},
{
id: 'topline',
position: { cartographicDegrees: [116.404, 39.918, 2400] },
polyline: {
positions: {
cartographicDegrees: [
116.344, 39.884, 900,
116.372, 39.906, 1600,
116.404, 39.918, 2400,
116.442, 39.906, 1500,
116.452, 39.884, 800
]
},
width: 2,
material: { polylineGlow: { color: { rgba: [255, 214, 102, 255] }, glowPower: 0.25 } }
}
},
{
id: 'caption',
position: { cartographicDegrees: [116.404, 39.868, 0] },
label: {
text: '墙顶高度 900 / 1600 / 2400 / 1500 / 800 米',
font: '500 13px "Microsoft YaHei", sans-serif',
fillColor: { rgba: [216, 232, 250, 255] },
disableDepthTestDistance: Number.POSITIVE_INFINITY
}
}
];
Cesium.CzmlDataSource.load(data).then(function (ds) {
viewer.dataSources.add(ds);
});
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(116.398, 39.856, 22000),
orientation: {
heading: 0,
pitch: Cesium.Math.toRadians(-32),
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.