suerprisePlus
2024-08-14 d4a3ca549f8755c2f87442c27217c3be39cab5cc
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
272
273
274
275
276
277
278
279
280
281
282
283
284
<template>
    <div class="mapView">
        <div id="sdkContainer">
            <div class="menuBox">
                <!-- 一级菜单展示效果 -->
                <div class="menuContent" v-show="!menuIsShow" :class="{ menuActive: menuIsShow }">
                    <div class="menuItemBox" :id="item.id" v-for="(item, index) in menuOption" :key="index">
                        <!-- -->
                        <el-dropdown @command="handleCommand">
                            <span class="el-dropdown-link">
                                {{ item.name }}
                                <i v-show="item.children" class="el-icon-arrow-down el-icon--right"></i>
                            </span>
                            <div v-if="item.children">
                                <el-dropdown-menu v-show="item.children" slot="dropdown">
                                    <el-dropdown-item style="text-align: center" :command="res"
                                        v-for="(res, key) in item.children" :key="key">{{ res.name }}</el-dropdown-item>
                                </el-dropdown-menu>
                            </div>
                        </el-dropdown>
                    </div>
                    <!-- 关闭菜单事件 -->
                    <div class="closeMenu" @click="setMenuClose">
                        <i :size="20" class="el-icon-d-arrow-left"></i>
                    </div>
                </div>
                <!-- 菜单展开事件 -->
                <div v-show="menuIsShow" @click="menuIsShow = !menuIsShow" class="rightMenu">
                    <i :size="20" class="el-icon-d-arrow-left"></i>
                </div>
            </div>
            <!-- 图层管理 -->
            <layer-manager ref="layerManager"></layer-manager>
            <!-- 坐标定位 -->
            <location ref="location"></location>
            <!-- 知识图谱 -->
            <knowledge ref="knowledge"></knowledge>
            <!-- 线路漫游 -->
            <lineRoaming ref="lineRoaming"></lineRoaming>
            <!-- 地下模式 -->
            <undergroundMode ref="undergroundMode"></undergroundMode>
            <!-- 数据分析 -->
            <dataAnalysis ref="dataAnalysis"></dataAnalysis>
            <!-- 数据统计 -->
            <dataStatistics ref="dataStatistics"></dataStatistics>
            <!-- 属性信息 -->
            <attributeInfo ref="attributeInfo"></attributeInfo>
            <map-info :childObj="childObj" ref="mapInfo"></map-info>
        </div>
    </div>
</template>
 
<script>
import mapInit from '@/assets/js/mapSdk/index.js';
import mapData from '@/assets/js/mapSdk/mapData.js';
import layerManager from './layerManager.vue';
import menuManager from '@/assets/js/mapSdk/menuManager.js';
import location from './location.vue';
import knowledge from './knowledge.vue';
import lineRoaming from './lineRoaming.vue';
import { layer_selectAll } from "@/api/mapView/map.js";
import configTools from '@/assets/js/configTools';
import store from "@/store";
import mapServer from '@/assets/js/mapSdk/mapServe';
import undergroundMode from './undergroundMode.vue';
import dataAnalysis from './dataAnalysis.vue';
import dataStatistics from './dataStatistics.vue'
import attributeInfo from './attributeInfo.vue';
import mapInfo from './mapInfo.vue';
export default {
    name: 'mapView',
    components: { layerManager, location, knowledge, lineRoaming, undergroundMode, dataAnalysis, dataStatistics, attributeInfo, mapInfo },
    data() {
        return {
            menuIsShow: false,
            menuOption: [],
            childMenuIsShow: true,
            childMenuOption: [],
            childObj: [],
        };
    },
    mounted() {
        this.mapViewStart();
        this.$busEvent.$on('CHANGE_MAPINFO', res => {
 
            this.setMapInfo(res)
 
        });
 
    },
    beforeDestroy() {
        this.$store.dispatch('mapLayers/changeLayerTree', [])
        this.$store.dispatch('mapLayers/changeDefaultLayer', [])
    },
 
 
    methods: {
        setMapInfo(res) {
            // console.log(res);
            if (res.length > 0) {
                this.childObj = res;
                setTimeout(() => {
                    this.$refs && this.$refs.mapInfo && this.$refs.mapInfo.open();
                }, 200);
 
 
            }
 
        },
        mapViewStart() {
            this.menuOption = mapData.menuData;
            this.$nextTick(() => {
                mapInit.Init();
                setTimeout(() => {
                  if(config.baseModel.url){
                    mapServer.addLayer(config.baseModel);
                  }
                    this.getSelectLayers();
                }, 500);
 
            });
        },
        getSelectLayers() {
            layer_selectAll().then(response => {
                if (response.data.code != 200) return
                const defaultLayer = [];
                const val = response.data.result.filter(item => {
                    item.checked = false;
                    if (item.type == 2 && item.isShow == 1) {
                        item.checked = true;
                        mapServer.addLayer(item)
                        defaultLayer.push(item.id)
                    }
                    return item;
                })
                this.$store.dispatch('mapLayers/changeDefaultLayer', defaultLayer)
                var obj = configTools.getTreeData(val)
                this.$store.dispatch('mapLayers/changeLayerTree', obj)
            })
        },
        setMenuClose() {
            this.menuIsShow = !this.menuIsShowx;
        },
        setMenuClick(res) {
            if (res.children) return;
            menuManager.init(res);
        },
        handleCommand(command) {
            this.setPopCloseAll();
            const obj = menuManager.init(command);
            if (obj) {
                this.setPopShow(obj);
            }
        },
        setPopCloseAll() {
            this.$refs && this.$refs.layerManager && this.$refs.layerManager.close();
            this.$refs && this.$refs.location && this.$refs.location.close();
            this.$refs && this.$refs.knowledge && this.$refs.knowledge.close();
        },
        setPopShow(response) {
            console.log(response);
            switch (response) {
                case '图层管理':
                    this.$refs && this.$refs.layerManager && this.$refs.layerManager.open();
                    break;
                case '坐标定位':
                    this.$refs && this.$refs.location && this.$refs.location.open();
                    break;
                case '知识图谱':
                    this.$refs && this.$refs.knowledge && this.$refs.knowledge.open();
                    break;
                case '线路漫游':
                    this.$refs && this.$refs.lineRoaming && this.$refs.lineRoaming.open();
                    break;
                case '地下模式':
                    this.$refs && this.$refs.undergroundMode && this.$refs.undergroundMode.open();
                    break;
                case '数据分析':
                    this.$refs && this.$refs.dataAnalysis && this.$refs.dataAnalysis.open();
                    break;
                case '属性信息':
                    this.$refs && this.$refs.attributeInfo && this.$refs.attributeInfo.open();
                    break;
                case '数据统计':
                    this.$refs && this.$refs.dataStatistics && this.$refs.dataStatistics.open();
                    break;
                default:
                    break;
            }
        },
    },
};
</script>
 
<style lang="scss" scoped>
.mapView {
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    position: absolute;
    margin: 10px;
    border-radius: 5px;
 
    .menuBox {
        position: absolute;
        z-index: 40;
        top: 20px;
        right: 2px;
        border-radius: 0 6px 6px 0;
        font-family: microsoft yahei;
 
        .menuContent {
            display: flex;
            height: 40px;
            border: 1px solid rgb(245, 245, 245);
            border-radius: 5px 5px 5px 5px;
        }
 
        .menuActive {
            width: 0px;
            transition: width 10s linear 10s;
            -webkit-transition: width 10s linear 10s;
        }
 
        .rightMenu {
            width: 30px;
            height: 40px;
            background: rgba(255, 255, 255, 1);
            border: 1px solid rgb(245, 245, 245);
            color: #4ab1fc;
            display: flex;
            justify-content: center;
            align-items: center;
            border-radius: 5px;
        }
 
        .closeMenu {
            width: 30px;
            height: 100%;
            background: rgb(255, 255, 255);
            color: #4ab1fc;
            display: flex;
            position: relative;
            justify-content: center;
            align-items: center;
        }
 
        .menuItemBox {
            color: #7a7a7a;
            background: rgb(255, 255, 255);
            line-height: 40px;
            padding: 0px 10px;
            font-size: 14px;
        }
 
        .menuItemBox:hover {
            color: #4ab1fc;
        }
    }
 
    .childMenuBox {
        padding: 10px;
        width: auto;
        color: #7a7a7a;
        background: rgba(245, 245, 245, 1);
        position: absolute;
        z-index: 41;
        top: 123px;
        border-radius: 3px;
        min-width: 20px;
        transform: translate(-100%, 0);
        text-align: center;
        box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
 
        div {
            font-family: microsoft yahei;
            font-size: 12px;
        }
 
        div:hover {
            color: #4ab1fc;
        }
    }
}
</style>