在根目录index.html引入百度ak

<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=你的百度ak"></script>

安装echarts依赖包
npm i echarts

在项目引入

import echarts from 'echarts'
import 'echarts/extension/bmap/bmap'

添加地图容器

<div id="map" style="width: 900px;height: 800px;"></div>

js

//初始化
let myChart = echarts.init(document.getElementById('map')); 
//地图配置(option配置自行查看官方文档,文档还是很详细的)
myChart.setOption(option);
//官方文档地址https://echarts.apache.org/examples/zh/editor.html?c=map-polygon

效果图
image.png


唯风
3 声望0 粉丝