如何绘制中国地图或中国某一区域行政地图

13 阅读1分钟

1. 查找中国地图或需要绘制行政区域的JSON

查找地址:https://geojson.cn/

请求复制的地址,并保存数据 -> 获取到的数据则就是需要绘制的行政区域的数据

2. 下载echarts,进行使用

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

var myChart = echarts.init(document.getElementById('main'));
echarts.registerMap('ST', json); // json就是导入的json数据

myChart.setOption( // 设置地图数据
  (option = {
    toolbox: {
      show: true,
      orient: 'vertical',
      left: 'right',
      top: 'center',
      feature: {
      }
    },
    series: [
      {
        name: '地图',
        type: 'map',
        map: 'ST',
        label: {
          show: true
        },
      }
    ]
  })
);