相关实例
一.下载安装所需包
npm install echarts@4.9.0 --save //之所以下载4点几版本是因为5以上的版本没有地图包
npm install echarts-gl@1.1.0 --save //此版本更高的版本会报错如下:
This dependency was not found:
* echarts/lib/label/labelStyle in ./node_modules/echarts-gl/lib/component/common/LabelsBuilder.js, ./node_modules/echarts-gl/lib/component/grid3D/Grid3DAxis.js and 1 other
To install it, you can run: npm install --save echarts/lib/label/labelStyle
npm install china-map --save
在main.js 引入
import echarts from 'echarts'
Vue.prototype.$echarts = echarts; //将echarts 挂载到vue 实例上去
新建地图组件
<template>
<div class="earth_header" id="box" >
<div class="bottom_bg"></div>
</div>
</template>
<script>
import * as echarts from "echarts";
import 'echarts/map/js/china'
import 'echarts-gl';
export default {
data() {
return{
alirl : [
[
[121.15, 31.89],
[109.781327, 39.608266]
],
[
[120.38, 37.35],
[122.207216, 29.985295]
],
[
[123.97, 47.33],
[120.13, 33.38]
],
[
[118.87, 42.28],