// import EChartsLayer from 'ol-echarts';//support for openlayers5+;ol3-echarts--	support for openlayers3-4
import echarts from 'echarts';
// import ADLayer from 'openlayers_echart'
import ADLayer from './openlayers.echarts.js'
export function moveingLine(movingLineArray,map,backgroundColor){
    // let hStep = 300 / (movingLineArray.length - 1);
    // var rawData = [[1164383,401471,-11,-13,1,-49,-26,-14,99,-170,4,-36,87,-2,16,-141,-2,-15,-47,-6,-168,-9,-2,22,-74,-4,-138,10,12,-152,9,-55,-17,-111,13,-176,-20,-38,1,-57,31,-54,28,-85,-5,-126,-13,-62,1,-34,-84,1,-3,-218,15,6,78,2,4,-52,70,1,7,-142,99,2,21,-5,229,-150,16,-23,0,-180,168,1,-4,-257,82,0,33,-22,78,20]];
    let busLines = [].concat.apply([], movingLineArray.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': movingLineArray[idx],
          'lineStyle': {
            'normal': {
              'color': echarts.color.modifyHSL(backgroundColor.color, backgroundColor.round)
            }
          }
        };
    }));
    var option = {
        'series': [
          {
            'type': 'lines',
            'polyline': true,
            'data': busLines,
            'lineStyle': {
              'normal': {
                'width': 0
              }
            },
            'effect': {
              'constantSpeed': 60,
              'show': true,//是否显示特效。
              'trailLength': 0.9,//特效尾迹的长度。取从 0 到 1 的值，数值越大尾迹越长。
              'symbolSize':8.5////线两端的标记类型
            },
            'zlevel': 2
          }
        ]
      };
    var oe= new ADLayer(option,map,echarts) 
    oe.render()
    return oe
}
