echarts省级地图展示(包含3D地图)

1、npm i echarts --save
// main.js
import * as echarts from 'echarts';
Vue.prototype.$echarts = echarts
2、下载省级地图json(下载地址)
3、当前页面引入JSON
import chongqing from "./assets/chongqing.json"
4、使用
<template>
	<div id="mychart" style="width: 900px;height: 900px;"></div>
</template>
mounted() {
     this.$nextTick(()=>{
       this.mychart = this.$echarts.init(document.getElementById("mychart"));
       this.$echarts.registerMap("chosenMap", chongqing );
       let option = {
         backgroundColor: "#404a59",
         title: {
           text: "重庆",
           top: 25,
           left: "center",
           textStyle: {
             fontSize: 25,
             fontWeight: 650,
             color: "#fff",
           },
         },
         tooltip: {
           trigger: "item",
           formatter: function(val) {
             return "人数: 人";
           },
         },
         toolbox: {
           show: true,
           orient: "vertical",
           left: "right",
           top: "center",
           feature: {
             dataView: {
               readOnly: false
             },
             restore: {},
             saveAsImage: {},
           },
         },
         series: [{
           name: '重庆',
           type: "map",   //3D地图:map3D
           mapType: "chosenMap", // 自定义扩展图表类型
           label: {
             show: true,
           },
           itemStyle: {
             normal: {
               areaColor: "#323c48",
               borderColor: "#111",
               label: {
                 show: true,
                 color: "white",
               },
             },
             emphasis: {
               areaColor: "#2a333d",
               label: {
                 show: true,
                 color: "white",
               },
             },
           },
           roam: true,
           top: 70,
           label: {
             show: true, // 是否显示对应地名
           },
           data: [{
             name: "江津区",
             itemStyle: { // 单个区域的样式设置
               color: '#0489d6',
               areaColor: "blue",
               opacity: 1,
               borderWidth: 0.4,
               borderColor: 'red'
             },
             label: {
               show: true, //是否显示高亮
               textStyle: {
                 color: '#fff', //高亮文字颜色
               }
             },
           }]
         }, ],
       };
       this.mychart.on("click", function(params) {
         console.log(params);
       });
       this.mychart.setOption(option);
     })
    },
5、3D地图配置
  1. 下载echarts-gl :npm i echarts-gl --save
  2. 当前页面引入
import “echarts-gl”
  1. 参数配置
series: [
    {
        type: 'map3D',           
        name: '重庆', 
        selectedMode:"single",//地图高亮单选
        boxDepth:90,//地图倾斜度
        regionHeight:8,//地图高度
        map: '重庆',
        viewControl:{
            distance:150,//地图视角 控制初始大小
            rotateSensitivity:0,//禁止旋转
            zoomSensitivity:0,//禁止缩放
        }
  }]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

前端阿皓

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值