Atlaslog
Atlaslog / Examples / deck.gl / Arc Curve
deck.gl · Runnable Example

Arc Curve

Runnable deck.gl example: Arc Curve. 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 deck.gl examples
/demos/deckgl-arc-curve.htmlLIVE
single HTML file · CDN dependencies onlyinterface may contain Chinese labels

Source

demos/deckgl-arc-curve.html
<!--
  示例:弧线弯曲
  要点:ArcLayer 的 getHeight 与 getTilt 控制弧顶高度与倾斜,按距离分段
  依赖:deck.gl 9.0 · 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>弧线弯曲</title>
<style>
  html,body{height:100%;margin:0;background:#0d1117}
  body{display:flex;flex-direction:column;overflow:hidden;
       font:13px/1.6 -apple-system,"Segoe UI","PingFang SC",sans-serif;color:#e6e8ec}
  .bar{position:relative;z-index:5;flex:0 0 auto;padding:8px 12px;background:#161b22;border-bottom:1px solid #252c36;
       display:flex;gap:14px;align-items:center;font-size:12px;color:#8b93a1;flex-wrap:wrap}
  .bar b{color:#58a6ff;font-weight:600}
  .bar label{display:flex;align-items:center;gap:5px;cursor:pointer}
  .bar input[type=checkbox]{accent-color:#4f9ef8}
  .bar input[type=range]{width:150px;accent-color:#4f9ef8}
  .bar button{font:inherit;font-size:12px;padding:3px 10px;border-radius:4px;cursor:pointer;
       border:1px solid #2f3947;background:#1d242e;color:#c9d3e0}
  .bar button:hover{background:#26303d}
  #cv{flex:1 1 auto;min-height:0;width:100%;display:block}

</style>
</head>
<body>
<div class="bar"><span>航线 <b id="n">—</b></span><span>弧高按距离分段 · 悬停查看</span></div>
<canvas id="cv"></canvas>
<script src="https://cdn.jsdelivr.net/npm/deck.gl@9.0.35/dist.min.js"></script>
<script>
(function () {
  'use strict';

  if (typeof deck === 'undefined') {
    document.body.innerHTML =
      '<div style="padding:24px;color:#ff8c74">deck.gl 加载失败,请检查能否访问 cdn.jsdelivr.net</div>';
    return;
  }
  var hub = [116.39, 39.90];
  var dest = [
    ['上海', [121.47, 31.23], 1067], ['广州', [113.26, 23.12], 1888],
    ['成都', [104.06, 30.57], 1550], ['西安', [108.94, 34.34], 910],
    ['乌鲁木齐', [87.61, 43.82], 2400], ['昆明', [102.71, 25.04], 2100],
    ['哈尔滨', [126.64, 45.75], 1050]
  ];

  var arcs = dest.map(function (d) {
    return {
      name: d[0], from: hub, to: d[1], km: d[2],
      height: d[2] > 1800 ? 0.55 : (d[2] > 1000 ? 0.35 : 0.18),
      tilt: d[2] > 1800 ? 0 : (d[2] > 1000 ? 15 : 30)
    };
  });

  document.getElementById('n').textContent = arcs.length;

  var deckgl = new deck.Deck({
    canvas: 'cv',
    width: '100%',
    height: '100%',
    initialViewState: { longitude: 108, latitude: 39, zoom: 4.2, pitch: 42, bearing: -8 },
    controller: true,
    layers: [
      new deck.ArcLayer({
        id: 'arcs',
        data: arcs,
        getSourcePosition: function (d) { return d.from; },
        getTargetPosition: function (d) { return d.to; },
        getSourceColor: [96, 186, 255, 225],
        getTargetColor: [255, 176, 92, 225],
        getWidth: function (d) { return 2 + d.km / 900; },
        widthUnits: 'pixels',
        getHeight: function (d) { return d.height; },
        getTilt: function (d) { return d.tilt; },
        greatCircle: true,
        pickable: true
      })
    ],
    getTooltip: function (info) {
      if (!info.object) return null;
      return '北京 → ' + info.object.name + ' · ' + info.object.km + ' km';
    }
  });
  window.__deck = deckgl;
})();
</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 deck.gl examples

deck.gl · EXAMPLEBasemap Esri deck.gl · EXAMPLEBitmap deck.gl · EXAMPLEBoilerplate