VueECharts5.2.2 地图飞线实例
VueECharts5.2.2 地图飞线实例
VueECharts5.2.2 地图飞线实例

地图实现

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<template>
<div class="hello">
涟漪特效动画
<div id="myChart" ref="myChart" style="width: 700px;height:500px;"></div>
</div>
</template>

<script>
var echarts = require("echarts");
import {planePath} from "./map/dataPlanePath"

export default {
name: 'effectScatter',
data () {
return {
msg: '涟漪特效动画 effectScatter',
geoCoordMapChina: {
'新疆': [87.36, 43.45],
'北京': [116.413554, 39.911013],
'杭州': [120.161693, 30.280059],
'广东': [113.14, 23.08],
},
planePath: planePath
}
},
mounted() {
this.drawMap();
},
methods: {
/**
* 地图
*/
drawMap() {
let planePath = this.planePath; // fei_tip: 见下面

// 接口给的数据格式---可以考虑用这种格式
// let resData = [ // todo: 接口数据
// {"name": "杭州", "value": 60},
// {"name": "广东", "value": 59},
// {"name": "新疆", "value": 15}
// ];

let _data = [
[{"name": "北京", "value": 60}, {name: '杭州'}],
[{"name": "广东", "value": 59}, {name: '杭州'}],
[{"name": "新疆", "value": 15}, {name: '杭州'}],
];

let option = {
tooltip: {
trigger: 'item',
formatter: function (params) {
if (params.seriesType === "effectScatter") {
return "线路:" + params.data.name + "" + params.data.value[2];
} else if (params.seriesType === "lines") {
return params.data.fromName + ">" + params.data.toName + "<br />" + params.data.value;
} else {
return params.name;
}
}
},
geo: {
show: true,
map: 'china',
roam: false,
},
series: [
{ // 地图
type: 'map',
map: 'china',
roam: false, //是否开启鼠标缩放和平移漫游
label: {
show: true, //显示省份标签
color: "#90ee90",
},
itemStyle: { // 地图整体背景颜色
areaColor: "#c0c0c0"
}
},
{ // fei_tip:线路
name: '杭州Top3',
type: 'lines',
zlevel: 2,
symbol: ['none', 'arrow'],
symbolSize: 10,
effect: {
show: true,
period: 6,
trailLength: 0,
symbol: planePath,
symbolSize: 15
},
lineStyle: {
color: '#2d9df1', //航线的颜色
width: 1,
opacity: 0.6,
curveness: 0.2 // 弯曲程度
},
data: this.convertData(_data)
},
{
type: 'effectScatter', // fei_tip: 点名字
coordinateSystem: 'geo', // fei_tip: 使用地理坐标系
zlevel: 2,
rippleEffect: { //涟漪特效
period: 4, //动画时间,值越小速度越快
brushType: 'stroke', //波纹绘制方式 stroke, fill
scale: 4 //波纹圆环最大限制,值越大波纹越大
},
label: {
show: true,
position: 'right', //显示位置
offset: [5, -10], //偏移设置
formatter: function (params) {// 圆环显示文字
return params.data.name;
},
fontSize: 13,
color: '#ff6b81',
},
symbol: 'circle',
symbolSize: function (val) {
return 6; //圆环大小
},
itemStyle: {
show: true,
color: '#90a5dc' // 圆环颜色
},
data: [ // todo:fei_tip
{name: '北京', value: [116.413554, 39.911013, 60]},
{name: '广东', value: [113.14, 23.08, 59]},
{name: '新疆', value: [87.36, 43.45, 15]},
]
},
{ // 目的地样式
name: '杭州',
type: 'effectScatter',
coordinateSystem: 'geo',
zlevel: 2,
rippleEffect: {
brushType: 'stroke'
},
label: {
show: true,
position: 'right',
formatter: '{b}',
color: '#ff6b81'
},
symbolSize: function (val) {
return 8
},
itemStyle: {
color: '#fe4272',
},
data: [
{name: '杭州', value: [120.161693, 30.280059, null]},
]
}
],
};

let myChart = echarts.init(document.getElementById("myChart"));
myChart.setOption(option,true)
},
convertData(data) {
let res = [];
for (var i = 0; i < data.length; i++) {
let dataItem = data[i];
let fromCoord = this.geoCoordMapChina[dataItem[0].name];
let toCoord = [119.5313, 29.8773]; // todo:fei_tip:???
if (fromCoord && toCoord) {
res.push({
fromName: dataItem[0].name,
toName: dataItem[1].name,
coords: [fromCoord, toCoord],
value: dataItem[1].value
});
}
}
return res;
}
}
}
</script>


<style scoped>

</style>

ECharts map

航线planePath

1
2
// 航线
export const planePath = 'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z';

汽车行驶图

1
2
// 汽车行驶图
export const planePath = 'path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,13.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5C17.6,3.5,6.8,14.4,6.8,27.6c0,13.3,10.8,24.1,24.101,24.1C44.2,51.7,55,40.9,55,27.6C54.9,14.4,44.1,3.5,30.9,3.5z M36.9,35.8c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H36c0.5,0,0.9,0.4,0.9,1V35.8z M27.8,35.8 c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H27c0.5,0,0.9,0.4,0.9,1L27.8,35.8L27.8,35.8z';

effectScatter-涟漪特效 配置