pyt
2025-03-24 480dda90912926b1f6fbf971f1be8fe19c2b54a3
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<template>
    <div class="map-container">
        <div class="chart" ref="myMap" />
    </div>
</template>
 
<script>
import mapBg from "@/assets/map/mapBg.png";
import tooltipBg from "@/assets/map/tooltipBg.png";
import tooltipBlue from "@/assets/map/tooltipBlue.png";
import tooltipOrange from "@/assets/map/tooltipOrange.png";
 
export default {
    name: 'Map',
    props: {
        data: {
            type: Array,
            default: () => []
        }
    },
    data() {
        return {
            mapBg: null, // 地图背景图片
            // 地图标记点数据
            mapPoints: [
                { name: "点位1", value: [103.6672, 30.6333], type: "blue", symbolSize: 32 },
                { name: "点位2", value: [103.6772, 30.6533], type: "orange", symbolSize: 32 },
                { name: "点位3", value: [103.6572, 30.6433], type: "blue", symbolSize: 32 },
                { name: "点位4", value: [103.6872, 30.6633], type: "orange", symbolSize: 32 },
                { name: "点位5", value: [103.6472, 30.6233], type: "blue", symbolSize: 32 }
            ]
        }
    },
    created() {
        if (Object.keys(this.data).length > 0) {
            console.log(this.data);
            // this.mapPoints = this.data.mapResponses;
        }
    },
    mounted() {
        this.initMap();
    },
    methods: {
        initMap() {
            let mapJson = require("@/utils/map/chongzhou.json");
            let myChart = this.$echarts.init(this.$refs.myMap);
            myChart.showLoading();
            myChart.hideLoading();
            this.$echarts.registerMap("myMap", mapJson);
 
            let option = {
                tooltip: {
                    show: false
                },
                geo: [
                    this.getGeoLayers(1),
                    this.getGeoLayers(2),
                    this.getGeoLayers(3)
                ],
                series: [
                    {
                        type: "map",
                        name: "地图",
                        selectedMode: false,
                        aspectScale: 1,
                        zoom: 1,
                        roam: false,
                        regionHeight: 2,
                        map: "myMap",
                        z: 10,
                        top: "14%",
                        bottom: "11%",
                        viewControl: {
                            distance: 115,
                            alpha: 40,
                            rotateSensitivity: [0, 0],
                            beta: 0
                        },
                        label: {
                            show: false,
                            textStyle: {
                                color: "#fff",
                                fontSize: 10,
                                fontWeight: "normal",
                                opacity: 1
                            }
                        },
                        itemStyle: {
                            areaColor: {
                                type: 'pattern',
                                image: mapBg,
                                repeat: 'no-repeat',
                                imageSize: '100%',
                                patternSize: [815, 534],
                                patternPosition: [0, 0]
                            },
                            borderColor: "#324D6B",
                            borderWidth: 2,
                        },
                        emphasis: {
                            disabled: false,
                            label: {
                                show: false,
                                textStyle: {
                                    color: "#fff",
                                    fontSize: 10,
                                    fontWeight: "normal",
                                    opacity: 1
                                }
                            },
                            itemStyle: {
                                areaColor: {
                                    type: 'pattern',
                                    image: this.mapBg,
                                    repeat: 'no-repeat',
                                    imageSize: '100%',
                                    patternSize: [815, 534],
                                    patternPosition: [0, 0]
                                },
                                borderColor: "#00eaff",
                                borderWidth: 2,
                                shadowColor: "#00eaff",
                                shadowBlur: 25,
                                shadowOffsetX: 0,
                                shadowOffsetY: 0,
                                opacity: 1
                            }
                        },
                        select: {
                            disabled: true
                        },
                        light: {
                            main: {
                                color: "#00eaff",
                                intensity: 1.2,
                                shadow: true,
                                shadowQuality: 'ultra',
                                alpha: 40,
                                beta: 0
                            },
                            ambient: {
                                color: "#00eaff",
                                intensity: 0.3
                            }
                        },
                        tooltip: {
                            show: false
                        },
                        silent: false  // 禁用鼠标事件
                    },
                    this.getMarkerSeries("blue"),
                    this.getMarkerSeries("orange")
                ]
            };
            myChart.setOption(option);
        },
        // 生成标记点配置的方法
        getMarkerSeries(type) {
            return {
                name: type === "blue" ? "蓝色标记" : "橙色标记",
                type: "scatter",
                coordinateSystem: "geo",
                geoIndex: 0,
                data: this.mapPoints.filter(point => point.type === type),
                symbol: `image://${type === "blue" ? tooltipBlue : tooltipOrange}`,
                symbolSize: [20, 30],
                symbolOffset: [0, -15],
                z: 20,
                tooltip: {
                    show: true,
                    trigger: 'item',
                    backgroundColor: 'transparent',
                    borderWidth: 0,
                    padding: [0, 0, 0, 0],
                    position: function (point) {
                        return [point[0] - 100, point[1] - 160];
                    },
                    formatter: function (params) {
                        return `<div style="
                            background: url(${tooltipBg}) no-repeat center center;
                            background-size: 100% 100%;
                            width: 211px;
                            padding-bottom: 24px;
                            display: flex;
                            flex-direction: column;
                            justify-content: center;
                            align-items: center;
                        ">
                            <div style="color: #fff; font-size: 16px; margin: 21px 0;font-weight: bold;">${params.name}</div>
                            <div style="display: flex; justify-content: space-around; width: 100%;">
                                <div style="text-align: center;">
                                    <div style="color: rgba(102, 255, 255, 1); font-size: 20px;margin-bottom: 8px;font-family: 'pangmenzhengdao';">99999</div>
                                    <div style="color: #fff; font-size: 12px;">安置户数(户)</div>
                                </div>
                                <div style="text-align: center;">
                                    <div style="color: rgba(102, 255, 255, 1); font-size: 20px;margin-bottom: 8px;font-family: 'pangmenzhengdao';">99999</div>
                                    <div style="color: #fff; font-size: 12px;">安置人数(人)</div>
                                </div>
                            </div>
                        </div>`;
                    }
                },
                label: {
                    show: false
                },
                emphasis: {
                    scale: true,
                    scaleSize: 1.2,
                    itemStyle: {
                        shadowBlur: 10,
                        shadowColor: type === "blue" ? '#00eaff' : '#ff8e3a'
                    }
                }
            };
        },
        // 生成geo层级配置的方法
        getGeoLayers(index) {
            const layerConfig = {
                1: { top: "15%", bottom: "10%", borderColor: "#00A0F5", borderWidth: 1 },
                2: { top: "16%", bottom: "9%", borderColor: "#0C93C5", borderWidth: 1 },
                3: { top: "17%", bottom: "8%", borderColor: "#0A5C83", borderWidth: 2 }
            };
 
            const config = layerConfig[index];
            return {
                map: "myMap",
                aspectScale: 1,
                zoom: 1,
                roam: false,
                top: config.top,
                bottom: config.bottom,
                z: index,
                itemStyle: {
                    areaColor: "transparent",
                    borderColor: config.borderColor,
                    borderWidth: config.borderWidth,
                    ...(index === 3 ? {
                        shadowColor: "#00eaff",
                        shadowBlur: 25,
                        shadowOffsetX: 0,
                        shadowOffsetY: 0,
                        opacity: 1
                    } : {})
                },
                emphasis: {
                    disabled: true
                },
                select: {
                    disabled: true
                },
                tooltip: {
                    show: false
                },
                silent: true
            };
        },
    }
}
</script>
 
<style scoped>
.map-container {
    width: 815px;
    height: 534px;
}
 
.chart {
    width: 100%;
    height: 100%;
}
</style>