Atlaslog
Atlaslog / Examples / Cesium / Czml Circles Ellipses
Cesium · Runnable Example

Czml Circles Ellipses

Runnable Cesium example: Czml Circles Ellipses. Open the live demo, read the complete source, and copy the file into your project. No build step or API key.

Open standalone → Chinese notes All Cesium examples
/demos/cesium-czml-circles-ellipses.htmlLIVE
single HTML file · CDN dependencies onlyinterface may contain Chinese labels

Source

demos/cesium-czml-circles-ellipses.html
<!--
  示例:用 CZML 描述圆与椭圆
  说明:semiMajorAxis 与 semiMinorAxis 是半轴,相等就是圆;rotation 是长轴相对正北的角度
  核心逻辑: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 data = [
    { id: 'document', name: '圆与椭圆', version: '1.0' },
    {
      id: 'circle',
      name: '圆:两个半轴相等',
      position: { cartographicDegrees: [116.352, 39.895, 0] },
      ellipse: {
        semiMajorAxis: 26000,
        semiMinorAxis: 26000,
        height: 0,
        material: { solidColor: { color: { rgba: [77, 155, 255, 165] } } },
        outline: true,
        outlineColor: { rgba: [180, 216, 255, 255] }
      }
    },
    {
      id: 'ellipse',
      name: '椭圆:长短轴不等并旋转',
      position: { cartographicDegrees: [116.428, 39.895, 0] },
      ellipse: {
        semiMajorAxis: 52000,
        semiMinorAxis: 18000,
        rotation: Cesium.Math.toRadians(35),
        height: 0,
        material: { solidColor: { color: { rgba: [240, 170, 70, 170] } } },
        outline: true,
        outlineColor: { rgba: [255, 224, 180, 255] }
      }
    },
    {
      id: 'label-circle',
      position: { cartographicDegrees: [116.352, 39.872, 0] },
      label: {
        text: '圆 · 26 km',
        font: '500 13px "Microsoft YaHei", sans-serif',
        fillColor: { rgba: [210, 232, 255, 255] },
        disableDepthTestDistance: Number.POSITIVE_INFINITY
      }
    },
    {
      id: 'label-ellipse',
      position: { cartographicDegrees: [116.428, 39.874, 0] },
      label: {
        text: '椭圆 · 52 × 18 km',
        font: '500 13px "Microsoft YaHei", sans-serif',
        fillColor: { rgba: [255, 232, 200, 255] },
        disableDepthTestDistance: Number.POSITIVE_INFINITY
      }
    }
  ];

  Cesium.CzmlDataSource.load(data).then(function (ds) {
    viewer.dataSources.add(ds);
  });

  viewer.camera.flyTo({
    destination: Cesium.Cartesian3.fromDegrees(116.390, 39.827, 165000),
    orientation: {
      heading: 0,
      pitch: Cesium.Math.toRadians(-42),
      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.

More Cesium examples

Cesium · EXAMPLECzml Colors Cesium · EXAMPLECzml Cones Cylinders Cesium · EXAMPLECzml Corridor