Fork me on GitHub
时钟canvas

vue使用echarts绘制河南地图并实现个人轨迹

1
import echarts from 'echarts';<br>import "echarts/map/js/province/henan.js";

  

1
<div id="hndt" style="width: 100%;height: 50%;"></div>

  轨迹数据没有贴完只有一个的其它的自己增加就行

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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//使用echarts.init()方法初始化一个Echarts实例,在init方法中传入echarts map的容器 dom对象
      var mapChart = echarts.init(document.getElementById('hndt'));
      // mapChart的配置
      var option = {
backgroundColor: "#0b1225",
        title: {
          text: '个人轨迹运行图',
          left: 'left',
          textStyle: {
            color: '#fff'
          }
        },
        tooltip: {
          trigger: 'item'
        },
        dataRange: {
          show: false,
          min: 0,
          max: 1000,
          text: ['High', 'Low'],
          realtime: true,
          calculable: true,
          color: ['orangered', 'yellow', 'lightskyblue']
        },
        toolbox: {
          show : true,
          feature : {
            // dataView : {
            //   show: true,
            //   readOnly: true,
            // },
            restore : {show: true},
            saveAsImage : {show: true}
          }
        },
        visualMap: {
          show: true,
          min: 0,
          max: 255,
          calculable: true,
          inRange: {
            color: ['aqua', 'lime', 'yellow', 'orange', '#ff3333']
          },
          textStyle: {
            color: '#12223b'
          }
        },
        geo: { // 这个是重点配置区
          map: '河南', // 表示河南地图
          roam: true,
          layoutCenter: ['50%', '50%'],
          layoutSize: "100%",
          label: {
            normal: {
              show: false, // 是否显示对应地名
              textStyle: {
                color: 'rgba(94,239,27,0.95)'
              }
            },
          },
          itemStyle: {
            normal: {
              areaColor: '#37376e',
              borderColor: 'rgba(0, 0, 0, 0.2)'
            },
            emphasis: {
              areaColor: null,
              shadowOffsetX: 0,
              shadowOffsetY: 0,
              shadowBlur: 20,
              borderWidth: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
          }
        },
        series: [
          {
            "type": "lines",
            "zlevel": 2,
            "effect": {
              "show": true,
              "period": 4,
              "trailLength": 0.02,
              "symbol": "arrow",
              "symbolSize": 5
            },
            "lineStyle": {
              "normal": {
                "width": 1,
                "opacity": 0.6,
                "curveness": 0.2
              }
            },
            "tooltip": {
              "trigger": "item"
            },
            "data": [
              {
                "fromName": "郑州市",
                "toName": "周口市",
                "value": 1,
                "coords": [
                  [
                    113.467,
                    34.623
                  ],
                  [
                    114.697,
                    33.625
 
                  ]
                ],           
              },
                       
            
          {
            "name": "地点",
            "type": "effectScatter",
            "coordinateSystem": "geo",
            "zlevel": 2,
            "rippleEffect": {
              "period": 4,
              "brushType": "stroke",
              "scale": 4
            },
            "tooltip": {
              "trigger": "item"
            },
            "label": {
              "normal": {
                "show": true,
                "position": "left",
                "offset": [
                  -5,
                  5
                ],
                "formatter": "{b}"
              },
              "emphasis": {
                "show": true
              }
            },
            "hoverAnimation": true,
            "symbol": "circle",
            "symbolSize": 5,
            "itemStyle": {
              "normal": {
                "show": false,
                "color": "#f00"
              }
            },
            "data": [
              {
                "name": "郑州市",
                "value": [
                  113.467,
                  34.623,
                  0
                ],
                tooltip:{
                  formatter:'时间:8:30am<br/>出发地:郑州市'
                },
              },
              {
                "name": "周口市",
                "value": [
                  114.697,
                  33.625,
                  1
                ]
              },  
            ]
          },
        ]
  };
      //设置图表的配置项
      mapChart.setOption(option);

  

posted @   dragonKings  阅读(3329)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
欢迎阅读『vue使用echarts绘制河南地图并实现个人轨迹』
     
点击右上角即可分享
微信分享提示