Merge branch 'master' of http://yun.pashanhoo.com:9090/bdc/bdcjg-web
Showing
2 changed files
with
95 additions
and
66 deletions
src/common/map/yushu.js
0 → 100644
This diff is collapsed.
Click to expand it.
1 | <template> | 1 | <template> |
2 | <!-- 地图 --> | 2 | <!-- 地图 --> |
3 | <Echart id="centreLeft2Chart" class="centreLeft2Chart":key="key" ref="centreLeft2ChartRef" width="100%" height="100%" | 3 | <Echart |
4 | :options="options"></Echart> | 4 | id="centreLeft2Chart" |
5 | class="centreLeft2Chart" | ||
6 | :key="key" | ||
7 | ref="centreLeft2ChartRef" | ||
8 | width="100%" | ||
9 | height="100%" | ||
10 | :options="options" | ||
11 | ></Echart> | ||
5 | </template> | 12 | </template> |
6 | 13 | ||
7 | <script> | 14 | <script> |
8 | import Echart from '@/common/echart'; | 15 | import Echart from "@/common/echart"; |
16 | import { mapGetters } from "vuex"; | ||
9 | export default { | 17 | export default { |
10 | data () { | 18 | data() { |
11 | return { | 19 | return { |
12 | options: {}, | 20 | options: {}, |
13 | max: "100", //最大value值 | 21 | max: "100", //最大value值 |
14 | min: "1", // 最小value值 | 22 | min: "1", // 最小value值 |
15 | key: 0 | 23 | key: 0, |
24 | mapjson: "", | ||
16 | }; | 25 | }; |
17 | }, | 26 | }, |
18 | components: { | 27 | components: { |
19 | Echart, | 28 | Echart, |
20 | }, | 29 | }, |
21 | created () { | 30 | created() {}, |
22 | require(`@/common/map/hanzhong.js`) | ||
23 | }, | ||
24 | props: { | 31 | props: { |
25 | cdata: { | 32 | cdata: { |
26 | type: Array, | 33 | type: Array, |
... | @@ -28,12 +35,15 @@ export default { | ... | @@ -28,12 +35,15 @@ export default { |
28 | }, | 35 | }, |
29 | }, | 36 | }, |
30 | mounted() { | 37 | mounted() { |
38 | |||
31 | window.addEventListener("resize", () => { | 39 | window.addEventListener("resize", () => { |
32 | this.key++ | 40 | this.key++; |
33 | }); }, | 41 | }); |
42 | this.getDistrictcode(); | ||
43 | }, | ||
34 | watch: { | 44 | watch: { |
35 | cdata: { | 45 | cdata: { |
36 | handler (newData) { | 46 | handler(newData) { |
37 | let _this = this; | 47 | let _this = this; |
38 | // 设置点的位置(经纬度) | 48 | // 设置点的位置(经纬度) |
39 | const geoCoordMap = { | 49 | const geoCoordMap = { |
... | @@ -52,92 +62,96 @@ export default { | ... | @@ -52,92 +62,96 @@ export default { |
52 | this.options = { | 62 | this.options = { |
53 | showLegendSymbol: true, | 63 | showLegendSymbol: true, |
54 | tooltip: { | 64 | tooltip: { |
55 | trigger: 'item', | 65 | trigger: "item", |
56 | textStyle: { | 66 | textStyle: { |
57 | fontSize: 14, | 67 | fontSize: 14, |
58 | lineHeight: 22, | 68 | lineHeight: 22, |
59 | }, | 69 | }, |
60 | position: point => { | 70 | position: (point) => { |
61 | // 固定在顶部 | 71 | // 固定在顶部 |
62 | return [point[0] + 50, point[1] - 20]; | 72 | return [point[0] + 50, point[1] - 20]; |
63 | }, | 73 | }, |
64 | // 如果需要自定义 tooltip样式,需要使用formatter | 74 | // 如果需要自定义 tooltip样式,需要使用formatter |
65 | formatter: params => { | 75 | formatter: (params) => { |
66 | return `<div style="">${params.name}:${params.value + "个"}</div>` | 76 | return `<div style="">${params.name}:${ |
67 | } | 77 | params.value + "个" |
78 | }</div>`; | ||
79 | }, | ||
68 | }, | 80 | }, |
69 | visualMap: { | 81 | visualMap: { |
70 | min: 0, | 82 | min: 0, |
71 | max: _this.max, | 83 | max: _this.max, |
72 | bottom: '13%', | 84 | bottom: "13%", |
73 | left: 50, | 85 | left: 50, |
74 | splitNumber: 6, | 86 | splitNumber: 6, |
75 | seriesIndex: [0], | 87 | seriesIndex: [0], |
76 | itemWidth: 20, // 每个图元的宽度 | 88 | itemWidth: 20, // 每个图元的宽度 |
77 | itemGap: 2, // 每两个图元之间的间隔距离,单位为px | 89 | itemGap: 2, // 每两个图元之间的间隔距离,单位为px |
78 | pieces: [ // 自定义每一段的范围,以及每一段的文字 | 90 | pieces: [ |
79 | { gte: 100, label: '100以上', color: '#035cf5' }, // 不指定 max,表示 max 为无限大(Infinity)。 | 91 | // 自定义每一段的范围,以及每一段的文字 |
80 | { gte: 50, lte: 6000, label: '20-100', color: '#3375e4' }, | 92 | { gte: 100, label: "100以上", color: "#035cf5" }, // 不指定 max,表示 max 为无限大(Infinity)。 |
81 | { gte: 20, lte: 2000, label: '1-200', color: '#6797ef' }, | 93 | { gte: 50, lte: 6000, label: "20-100", color: "#3375e4" }, |
82 | { gte: 1, lte: 1000, label: '1-20', color: '#96b5ef' }, | 94 | { gte: 20, lte: 2000, label: "1-200", color: "#6797ef" }, |
95 | { gte: 1, lte: 1000, label: "1-20", color: "#96b5ef" }, | ||
83 | ], | 96 | ], |
84 | textStyle: { | 97 | textStyle: { |
85 | color: '#737373' | 98 | color: "#737373", |
86 | } | 99 | }, |
87 | }, | 100 | }, |
88 | geo: { | 101 | geo: { |
89 | aspectScale: 1, //长宽比 | 102 | aspectScale: 1, //长宽比 |
90 | zoom: 1.1, | 103 | zoom: 1.1, |
91 | mapType: '', // 自定义扩展图表类型 | 104 | mapType: "", // 自定义扩展图表类型 |
92 | top: '15%', | 105 | top: "15%", |
93 | left: '10%', | 106 | left: "10%", |
94 | map: '汉中市', | 107 | map: "汉中市", |
95 | itemStyle: { | 108 | itemStyle: { |
96 | normal: {//阴影 | 109 | normal: { |
97 | areaColor: '#5689FD ', | 110 | //阴影 |
98 | shadowColor: '#21371d', | 111 | areaColor: "#5689FD ", |
112 | shadowColor: "#21371d", | ||
99 | borderWidth: 0, | 113 | borderWidth: 0, |
100 | shadowOffsetX: 2, | 114 | shadowOffsetX: 2, |
101 | shadowOffsetY: 25 | 115 | shadowOffsetY: 25, |
102 | } | 116 | }, |
103 | } | 117 | }, |
104 | }, | 118 | }, |
105 | series: [ | 119 | series: [ |
106 | { | 120 | { |
107 | type: 'map', | 121 | type: "map", |
108 | aspectScale: 1, //长宽比 | 122 | aspectScale: 1, //长宽比 |
109 | zoom: 1.1, | 123 | zoom: 1.1, |
110 | mapType: '汉中市', // 自定义扩展图表类型 | 124 | mapType: "汉中市", // 自定义扩展图表类型 |
111 | top: '15%', | 125 | top: "15%", |
112 | left: '10%', | 126 | left: "10%", |
113 | itemStyle: { | 127 | itemStyle: { |
114 | normal: { | 128 | normal: { |
115 | areaColor: 'rgba(19,54,162,.5)', | 129 | areaColor: "rgba(19,54,162,.5)", |
116 | borderColor: 'rgba(0,242,252,.5)', | 130 | borderColor: "rgba(0,242,252,.5)", |
117 | borderWidth: 2, | 131 | borderWidth: 2, |
118 | shadowBlur: 1, | 132 | shadowBlur: 1, |
119 | borderColor: 'rgb(155, 200, 200)', | 133 | borderColor: "rgb(155, 200, 200)", |
120 | shadowColor: '#44f2fc', | 134 | shadowColor: "#44f2fc", |
121 | } | 135 | }, |
122 | }, | 136 | }, |
123 | label: { | 137 | label: { |
124 | formatter: params => { | 138 | formatter: (params) => { |
125 | return `${params.name}\n${params.value+"个"}`; | 139 | return `${params.name}\n${params.value + "个"}`; |
126 | }, | 140 | }, |
127 | show: true, | 141 | show: true, |
128 | position: 'insideRight', | 142 | position: "insideRight", |
129 | textStyle: { | 143 | textStyle: { |
130 | fontSize: 14, | 144 | fontSize: 14, |
131 | color: '#efefef', | 145 | color: "#efefef", |
132 | }, | 146 | }, |
133 | emphasis: { | 147 | emphasis: { |
134 | textStyle: { | 148 | textStyle: { |
135 | color: '#fff', | 149 | color: "#fff", |
136 | } | 150 | }, |
137 | } | 151 | }, |
138 | }, | 152 | }, |
139 | data: newData, | 153 | data: newData, |
140 | } | 154 | }, |
141 | ], | 155 | ], |
142 | }; | 156 | }; |
143 | // 重新选择区域 | 157 | // 重新选择区域 |
... | @@ -148,9 +162,26 @@ export default { | ... | @@ -148,9 +162,26 @@ export default { |
148 | deep: true, | 162 | deep: true, |
149 | }, | 163 | }, |
150 | }, | 164 | }, |
165 | computed: { | ||
166 | ...mapGetters(["sidebar", "dicData"]), | ||
167 | logoName() { | ||
168 | return ( | ||
169 | this.dicData["sysCode"] && | ||
170 | this.dicData["sysCode"].filter((item) => item.DCODE == "areaMap") | ||
171 | ); | ||
172 | }, | ||
173 | }, | ||
151 | methods: { | 174 | methods: { |
175 | // 根据行政区代码匹配行政区 | ||
176 | getDistrictcode() { | ||
177 | console.log("this.logoName.DNAME", this.logoName.DNAME); | ||
178 | if ((this.logoName.DNAME = "map610700")) { | ||
179 | this.mapjson = "hanzhong"; | ||
180 | require(`@/common/map/${this.mapjson}.js`); | ||
181 | } | ||
182 | }, | ||
152 | // 开启定时器 | 183 | // 开启定时器 |
153 | startInterval () { | 184 | startInterval() { |
154 | const _self = this; | 185 | const _self = this; |
155 | // 应通过接口获取配置时间,暂时写死5s | 186 | // 应通过接口获取配置时间,暂时写死5s |
156 | const time = 2000; | 187 | const time = 2000; |
... | @@ -162,7 +193,7 @@ export default { | ... | @@ -162,7 +193,7 @@ export default { |
162 | }, time); | 193 | }, time); |
163 | }, | 194 | }, |
164 | // 重新随机选中地图区域 | 195 | // 重新随机选中地图区域 |
165 | reSelectMapRandomArea () { | 196 | reSelectMapRandomArea() { |
166 | const length = 9; | 197 | const length = 9; |
167 | this.$nextTick(() => { | 198 | this.$nextTick(() => { |
168 | try { | 199 | try { |
... | @@ -172,27 +203,27 @@ export default { | ... | @@ -172,27 +203,27 @@ export default { |
172 | index = Math.floor(Math.random() * length); | 203 | index = Math.floor(Math.random() * length); |
173 | } | 204 | } |
174 | map.dispatchAction({ | 205 | map.dispatchAction({ |
175 | type: 'mapUnSelect', | 206 | type: "mapUnSelect", |
176 | seriesIndex: 0, | 207 | seriesIndex: 0, |
177 | dataIndex: this.preSelectMapIndex, | 208 | dataIndex: this.preSelectMapIndex, |
178 | }); | 209 | }); |
179 | map.dispatchAction({ | 210 | map.dispatchAction({ |
180 | type: 'showTip', | 211 | type: "showTip", |
181 | seriesIndex: 0, | 212 | seriesIndex: 0, |
182 | dataIndex: index, | 213 | dataIndex: index, |
183 | }); | 214 | }); |
184 | map.dispatchAction({ | 215 | map.dispatchAction({ |
185 | type: 'mapSelect', | 216 | type: "mapSelect", |
186 | seriesIndex: 0, | 217 | seriesIndex: 0, |
187 | dataIndex: index, | 218 | dataIndex: index, |
188 | }); | 219 | }); |
189 | this.preSelectMapIndex = index; | 220 | this.preSelectMapIndex = index; |
190 | } catch (error) { | 221 | } catch (error) { |
191 | console.log(error) | 222 | console.log(error); |
192 | } | 223 | } |
193 | }); | 224 | }); |
194 | }, | 225 | }, |
195 | handleMapRandomSelect () { | 226 | handleMapRandomSelect() { |
196 | this.$nextTick(() => { | 227 | this.$nextTick(() => { |
197 | try { | 228 | try { |
198 | const map = this.$refs.centreLeft2ChartRef.chart; | 229 | const map = this.$refs.centreLeft2ChartRef.chart; |
... | @@ -201,34 +232,32 @@ export default { | ... | @@ -201,34 +232,32 @@ export default { |
201 | _self.reSelectMapRandomArea(); | 232 | _self.reSelectMapRandomArea(); |
202 | }, 0); | 233 | }, 0); |
203 | // 移入区域,清除定时器、取消之前选中并选中当前 | 234 | // 移入区域,清除定时器、取消之前选中并选中当前 |
204 | map.on('mouseover', function (params) { | 235 | map.on("mouseover", function (params) { |
205 | clearInterval(_self.intervalId); | 236 | clearInterval(_self.intervalId); |
206 | map.dispatchAction({ | 237 | map.dispatchAction({ |
207 | type: 'mapUnSelect', | 238 | type: "mapUnSelect", |
208 | seriesIndex: 0, | 239 | seriesIndex: 0, |
209 | dataIndex: _self.preSelectMapIndex, | 240 | dataIndex: _self.preSelectMapIndex, |
210 | }); | 241 | }); |
211 | map.dispatchAction({ | 242 | map.dispatchAction({ |
212 | type: 'mapSelect', | 243 | type: "mapSelect", |
213 | seriesIndex: 0, | 244 | seriesIndex: 0, |
214 | dataIndex: params.dataIndex, | 245 | dataIndex: params.dataIndex, |
215 | }); | 246 | }); |
216 | _self.preSelectMapIndex = params.dataIndex; | 247 | _self.preSelectMapIndex = params.dataIndex; |
217 | }); | 248 | }); |
218 | // 移出区域重新随机选中地图区域,并开启定时器 | 249 | // 移出区域重新随机选中地图区域,并开启定时器 |
219 | map.on('globalout', function () { | 250 | map.on("globalout", function () { |
220 | _self.reSelectMapRandomArea(); | 251 | _self.reSelectMapRandomArea(); |
221 | _self.startInterval(); | 252 | _self.startInterval(); |
222 | }); | 253 | }); |
223 | this.startInterval(); | 254 | this.startInterval(); |
224 | } catch (error) { | 255 | } catch (error) { |
225 | console.log(error) | 256 | console.log(error); |
226 | } | 257 | } |
227 | }); | 258 | }); |
228 | }, | 259 | }, |
229 | }, | 260 | }, |
230 | }; | 261 | }; |
231 | </script> | 262 | </script> |
232 | <style> | 263 | <style></style> |
233 | |||
234 | </style> | ... | ... |
-
Please register or sign in to post a comment