圆弧和贝塞尔曲线
index.html
<!DOCTYPE html>
<html>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>图形 - 圆弧和贝塞尔曲线</title>
  <style type="text/css">
    html,body{margin:0px;height:100%;width:100%}
    .container{width:100%;height:100%}
  </style>
  <link rel="stylesheet" href="https://unpkg.com/maptalks/dist/maptalks.css">
  <script type="text/javascript" src="https://unpkg.com/maptalks/dist/maptalks.min.js"></script>
  <body>

    <div id="map" class="container"></div>

    <script>
      var map = new maptalks.Map('map', {
        center: [-0.11505,51.4985],
        zoom: 14,
        baseLayer: new maptalks.TileLayer('base', {
          urlTemplate: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
          subdomains: ['a','b','c','d'],
          attribution: '&copy; <a href="http://osm.org">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/">CARTO</a>'
        })
      });

      var c = new maptalks.Coordinate(-0.11305,51.4985);

      var arc = new maptalks.ArcCurve([
        c.add(-0.0202, 0.0081),
        c.add(-0.0269, 0.0069),
        c.add(-0.0369, 0.0032),
        c.add(-0.0314, -0.003),
        c.add(-0.0278, -0.008),
        c.add(-0.0220, -0.009)
      ], {
        'symbol' : getSymbol('Arc')
      });

      var quad = new maptalks.QuadBezierCurve([
        c.add(-0.0102, 0.0081),
        c.add(-0.0169, 0.0069),
        c.add(-0.0211, 0.0032),
        c.add(-0.0214, -0.0033),
        c.add(-0.0178, -0.0086),
        c.add(-0.0120, -0.0095)
      ], {
        'symbol' : getSymbol('Quadratic\nBézier')
      });

      var cubic = new maptalks.CubicBezierCurve([
        c.add(-0.0002, 0.0081),
        c.add(-0.0069, 0.0069),
        c.add(-0.0069, 0.0032),
        c.add(-0.0114, -0.0033),
        c.add(-0.0078, -0.0086),
        c.add(-0.0020, -0.0095)
      ], {
        'symbol' : getSymbol('Cubic\nBézier')
      });

      new maptalks.VectorLayer('vector', [arc, quad, cubic]).addTo(map);

      function getSymbol(title) {
        return [
          {
            lineColor: '#34495e',
            lineWidth: 3
          },
          {
            markerType : 'ellipse',
            markerWidth : 8,
            markerHeight : 8,
            markerFill : '#f00',
            markerPlacement : 'vertex'
          },
          {
            textName : title,
            textFill : '#f00',
            textWeight : 'bold',
            textHaloColor : '#fff',
            textHaloRadius : 3,
            textSize : 20,
            textWrapCharacter : '\n'
          }
        ];
      }

    </script>
  </body>
</html>
已复制!