首页 / 浏览问题 / 云GIS / 问题详情
echarts报错
12EXP 2022年06月06日

使用产品:iserver 11 操作系统:win10
数据类型: url
问题详细描述:学习可视化中的北京市公交线路图时,调用echarts显示Cannot read properties of undefined (reading 'ecInstance')

$("#line").on("click", function () {
  $.get(
    "https://fastly.jsdelivr.net/gh/apache/echarts-website@asf-site/examples/data/asset/data/lines-bus.json",
    function (data) {
      var busLines = [].concat.apply(
        [],
        data.map(function (busLine, idx) {
          var prevPt;
          var points = [];
          for (var i = 0; i < busLine.length; i += 2) {
            var pt = [busLine[i], busLine[i + 1]];
            if (i > 0) {
              pt = [prevPt[0] + pt[0], prevPt[1] + pt[1]];
            }
            prevPt = pt;

            points.push([pt[0] / 1e4, pt[1] / 1e4]);
          }
          return {
            coords: points,
          };
        })
      );
      option = {
        series: [
          {
            type: "lines",
            coordinateSystem: "leaflet",
            polyline: true,
            data: busLines,
            silent: true,
            lineStyle: {
              normal: {
                color: "rgb(200, 35, 45)",
                opacity: 0.2,
                width: 1,
              },
            },
            progressiveThreshold: 500,
            progressive: 200,
          },
        ],
      };
      new L.supermap.echartsLayer(option).addTo(map);
    }
  );
});

1个回答

您好,看您的代码是要选取名为”line“的组件添加点击事件是吗,请问您在运行官网示例线路图 (supermap.io)的时候也会这样报错吗,如果没有报错,建议您检查一下这个点击事件以及绑定的组件呢

3,350EXP 2022年06月06日
...