Vue项目中echarts地图渲染各个省市级


首先先从下面的网址拿到想要地区的json数据

echarts地图各个省市级json数据

Vue代码

<template>
  <div class="container" style="height: 100%" ref="container"></div>
</template>
<script>
const echarts = require("echarts");
import "@/utils/guangdong";  //城市json数据
export default {
  name: "WuxiMap",
  mounted() {
    this.initCharts();
  },
  methods: {
    initCharts() {
      const myChart = echarts.init(this.$refs.container);

      const option = {
        title: {
          text: "佛山",
        },
        series: [
          {
            type: "map",
            map: "佛山",
          },
        ],
      };
      myChart.setOption(option);
    },
  },
};
</script>
<style lang="scss" scoped>
</style>

 城市js文件

(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['exports', 'echarts'], factory);
    } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
        // CommonJS
        factory(exports, require('echarts'));
    } else {
        // Browser globals
        factory({}, root.echarts);
    }
}(this, function (exports, echarts) {
    var log = function (msg) {
        if (typeof console !== 'undefined') {
            console && console.error && console.error(msg);
        }
    }
    if (!echarts) {
        log('ECharts is not Loaded');
        return;
    }
    if (!echarts.registerMap) {
        log('ECharts Map is not loaded')
        return;
    }
    echarts.registerMap('佛山', 城市JSON)}));

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM