echarts地图画线
时间: 2023-11-02 11:07:46 浏览: 185
您好,关于echarts地图画线,可以使用echarts提供的geo组件和lines组件来实现。具体步骤如下:
1. 引入echarts库和地图数据
```html
<script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts/dist/extension/bmap.min.js"></script>
```
```javascript
// 引入地图数据
echarts.registerMap('china', chinaMapData);
```
2. 配置geo组件和lines组件
```javascript
option = {
geo: {
map: 'china',
roam: true,
label: {
emphasis: {
show: false
}
},
itemStyle: {
normal: {
areaColor: '#323c48',
borderColor: '#111'
},
emphasis: {
areaColor: '#2a333d'
}
}
},
series: [{
type: 'lines',
coordinateSystem: 'geo',
data: [{
fromName: '北京',
toName: '上海',
coords: [
[116.46, 39.92],
[121.48, 31.22]
]
}],
// 线条样式配置
polyline: true,
lineStyle: {
normal: {
color: '#c23531',
width: 2,
opacity: 0.5,
curveness: 0.2
}
}
}]
};
```
3. 渲染地图
```javascript
var myChart = echarts.init(document.getElementById('main'));
myChart.setOption(option);
```
阅读全文