使用产品: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);
}
);
});