前端札记 前端札记
首页
    • 前端
    • 服务器
    • 其他
  • 分类
  • 归档
  • 标签
GitHub (opens new window)

Xin

面朝大海,春暖花开
首页
    • 前端
    • 服务器
    • 其他
  • 分类
  • 归档
  • 标签
GitHub (opens new window)
  • 折线、柱状图

  • 饼图

  • 地图

    • 地图2D
    • 地图3D
  • 《Echarts》笔记
  • 地图
Xin
2024-07-17

地图3D

<template>
  <div ref="henan_map" style="width: 100%; height: 83vh" />
</template>

<script>
export default {
  data() {
    return {
      henanJson: require('/docs/.vuepress/utils/河南省.json'),
    };
  },
  mounted() {
    this.initChart();
  },
  methods: {
    initChart() {
      const chart = echarts.init(this.$refs.henan_map);
      echarts.registerMap('henan', this.henanJson);

      let option = {
        tooltip: {
          show: true,
          trigger: 'item',
        },
        series: [
          {
            type: 'map3D',
            map: 'henan',
            boxWidth: 80,
            boxDepth: 100,
            regionHeight: 3,
            selectedMode: 'multiple',
            shading: 'color',
            //鼠标旋转,缩放等视觉设置
            viewControl: {
              center: 0,
              beta: 0, // 视角方向
              rotateSensitivity: 0,
              projection: 'orthographic',
              minOrthographicSize: 75,
              autoRotate: false,
              zoomSensitivity: 0, // 禁止缩放
            },
            instancing: true,
            //标签样式
            label: {
              show: true,
              distance: 0,
              textStyle: {
                color: '#000',
                fontWeight: 'bold',
                fontSize: 18,
              },
            },
            itemStyle: {
              color: 'rgba(235,245,255,0.5)',
              borderColor: '#CCC',
              borderWidth: 1,
            },
            emphasis: {
              label: {
                show: true,
                fontWeight: 'bold',
                fontSize: 18,
                color: 'red',
              },
              itemStyle: {
                color: 'rgba(246,227,17,0.1)',
              },
            },
          },
        ],
      };
      chart.setOption(option, true);
    },
  },
};
</script>
<style lang="scss" scoped></style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
显示代码 复制代码 复制代码
编辑 (opens new window)
#Echarts
上次更新: 2024-07-17 17:07:35
地图2D

← 地图2D

Theme by Vdoing | Copyright © 2021-2025
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式