当前位置:   article > 正文

openlayers 5.0结合echarts迁移图_new adlayer

new adlayer

1.通过npm安装 :npm install openlayers_echart
2.代码

import ADLayer from 'openlayers_echart'
//BJData数据格式  [
[[[{name:天津, value: 100, point: [106.7,32]}, {name: 北京, point: [107.9,34.3]}]]],
[[[{name:上海, value: 100, point: [108.7,32]}, {name: 大连, point: [109.9,34.3]}]]]
]
  static move(BJData){
    var convertData = function (data) {
      var res = [];
      for (var i = 0; i < data.length; i++) {
        var dataItem = data[i];
        var fromCoord =dataItem[0].point;
        var toCoord = dataItem[1].point;
        if (fromCoord && toCoord) {
          res.push([{
            coord: fromCoord,
            value: dataItem[0].value
          }, {
            coord: toCoord
          }]);
        }
      }
      return res;
    };
    var color = ['#a6c84c', '#ffa022', '#46bee9'];
    var series = [];
    BJData.forEach(function(item, i) {
      series.push(
        {
          type: 'lines',
          zlevel: 2,
          effect: {
            show: true,
            period: 4,
            trailLength: 0.02,
            symbol: 'arrow',
            symbolSize: 10,
          },
          lineStyle: {
            normal: {
              color:"#2985F7",
              width: 3,
              opacity: 0.6,
              curveness: 0.2
            }
          },
          data: convertData(item[0])
        },
      );
    });
    var option = {
      tooltip : {
        trigger: 'item'
      },
      series: series
    };
    var oe= new ADLayer(option,map,echarts)
    oe.render()
  }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/728187
推荐阅读
相关标签
  

闽ICP备14008679号