管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-08-14 04dae190af26730e8e0dcfb7cb4ec066400422f3
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
<template>
  <Popup
    ref="pop"
    :title="title"
    @close="close(true)"
    width="400px"
    @yes="addData"
    @cancel="close(false)"
  >
 
    <div
      id="archTopBox"
      class="archTopBox"
    >
 
      <div
        class="boxCard"
        v-for="(item,index) in mapList"
      >
        <el-card class="box-card">
          <div
            slot="header"
            class="clearfix"
          >
            <span style="font-size:14px">{{item.name}}</span>
            <div style="float: right; padding: 3px 0">
              <i
                v-show="!item.isShow"
                style="margin-left:10px"
                class="el-icon-arrow-up"
                :title="$t('archiveObj.fold')"
                @click="setCardChange(item)"
              ></i>
              <i
                v-show="item.isShow"
                style="margin-left:10px"
                class="el-icon-arrow-down"
                :title="$t('archiveObj.develop')"
                @click="setCardChange(item)"
              ></i>
            </div>
          </div>
          <div
            :id="item.id"
            style="margin:5px 1px"
            v-show="!item.isShow"
          >
            <div style="margin:10px;width:380px">
              <div
                class="map"
                v-for="(map, mapIndex) in item.list"
                @click="addImageLayer(map, item)"
              >
                <img
                  style="width: 60px; height: 60px"
                  :src="map.image"
                ></img>
                <div> <el-link :underline="false">
                    {{ map.name }}
                  </el-link></div>
              </div>
            </div>
          </div>
        </el-card>
 
      </div>
 
      <!-- <el-collapse :value="activeNames">
          <el-collapse-item
            v-for="(mapCollection, index) in mapList"
            :title="mapCollection.name"
            :name="mapCollection.name"
            :key="index"
          >
            <div
              class="map"
              v-for="(map, mapIndex) in mapCollection.list"
              :key="mapIndex"
              @click="addImageLayer(map, mapCollection)"
            >
              <el-image
                style="width: 60px; height: 60px"
                :src="require(`@assets/imageLayer/${map.image}`)"
                fit="fill"
              ></el-image>  
        <span>{{ map.name }}</span>
      </div>
      </el-collapse-item>
      </el-collapse> -->
    </div>
    </el-form>
  </Popup>
</template>
 
<script>
import Popup from "./Popup";
import TileLayer from "ol/layer/Tile"
import XYZ from "ol/source/XYZ"
// 影像图层
 
export default {
  name: "AddOnlineMap",
  components: {
    Popup,
  },
  mixins: [],
  data() {
    return {
      title: "在线地图",
      left: undefined,
      tokne: "",
      data: {
        id: "",
        sourceType: "",
        name: "",
        urls: "",
        layer: "",
        alpha: 1,
        maximumLevel: 26,
        zIndex: undefined,
      },
      mapCollection: undefined,
      mapList: [{
        name: "Cesium",
        sourceType: "cesium",
        tokne: "94a34772eb88317fcbf8428e10448561",
        maximumLevel: 18,
        id: 1,
        isShow: true,
        list: [{
          name: "Cesium影像",
          image: require("../../assets/img/imageLayer/tdmap_image.jpg"),
          urls: "https://webst02.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
        },],
      },
 
      {
        name: "天地图",
        sourceType: "tdmap",
        tokne: "94a34772eb88317fcbf8428e10448561",
        maximumLevel: 18,
        id: 1,
        isShow: true,
        list: [
          {
            name: "天地图地图",
            image: require("../../assets/img/imageLayer/tdmap_map.jpg"),
            urls: "http://t0.tianditu.com/vec_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=vec&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=",
            olUrls: 'http://t0.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk='
          },
          {
            name: "天地图影像",
            image: require("../../assets/img/imageLayer/tdmap_image.jpg"),
            urls: "http://t0.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=",
            olUrls: 'http://t0.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk='
          },
          {
            name: "天地图地形",
            image: require("../../assets/img/imageLayer/tdmap_label.jpg"),
            urls: "http://t0.tianditu.com/ter_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=ter&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=",
            olUrls: 'http://t0.tianditu.gov.cn/DataServer?T=ter_w&x={x}&y={y}&l={z}&tk='
          },
        ],
      },
      {
        name: "高德地图",
        sourceType: "gdmap",
        maximumLevel: 18,
        id: 2,
        isShow: true,
        list: [
          {
            name: "高德地图",
            image: require("../../assets/img/imageLayer/gdmap_map.jpg"),
            urls: "https://webst02.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}",
          },
          {
            name: "高德影像",
            image: require("../../assets/img/imageLayer/gdmap_image.jpg"),
            urls: "https://webst02.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
          },
 
        ],
      }, {
        name: '本地服务',
        sourceType: 'localmap',
        maximumLevel: 22,
        id: 3,
        isShow: true,
        list: [
          {
            name: "地图",
            image: require("../../assets/img/imageLayer/gdmap_map.jpg"),
            urls: "http://{host}/LFData/2d/tiles/vec/{z}/{x}/{y}.png",
          },
          {
            name: "影像",
            image: require("../../assets/img/imageLayer/gdmap_image.jpg"),
            urls: "http://{host}/LFData/2d/tiles/img/{z}/{x}/{y}.png",
          },
          {
            name: "地形",
            image: require("../../assets/img/imageLayer/dixing.png"),
            urls: "http://{host}/LFData/2d/tiles/ter/{z}/{x}/{y}.png",
          },
          {
            name: "1:20万区域地质图",
            image: require("../../assets/img/imageLayer/25dizhi.png"),
            urls: "http://{host}/LFData/2d/tiles/20w_qydz/{z}/{x}/{y}.png",
          },
        ],
      }
 
      ],
    };
  },
  computed: {
    activeNames() {
      return this.mapList.map((item) => {
        return item.name;
      });
    },
  },
  methods: {
    setCardChange(res) {
      res.isShow = !res.isShow
    },
    // 关闭弹窗
    close(isCloseBtn, removeLayer = true) {
      //   removeLayer && this.removeImageLayer();
 
      // 重置data值
      Object.assign(this.$data, this.$options.data());
      !isCloseBtn && this.$refs.pop.close();
    },
    // 打开弹窗
    open() {
      this.close(true);
      this.$refs.pop.open();
 
    },
    changeToken(token) {
      this.mapCollection.tokne = token;
    },
    removeImageLayer() {
      //   window.BaseMapLayer && window.BaseMapLayer.deleteObject();
      //   window.BaseMapLayer = undefined;
      window.Viewer.imageryLayers.remove(
        window.BaseMapLayer
      );
      window.map.removeLayer(window.olBaseMapLayer);
      if (!is_production) {
        if (window.vectorLayer) {
          window.map.removeLayer(window.vectorLayer);
        }
      }
    },
    addImageLayer(map, mapCollection) {
 
      if (
        this.data.name === map.name &&
        (this.data.urls === map.urls || this.data.urls === mapCollection.urls)
      ) {
        return;
      }
 
      this.removeImageLayer();
 
      this.mapCollection = mapCollection;
      if (mapCollection.sourceType === "cesium") {
        window.olBaseMapLayer = new TileLayer({
          title: "高德地图",
          source: new XYZ({
            url: map.urls,
            wrapX: false
          }),
          zIndex: -1
        });
        window.map.addLayer(window.olBaseMapLayer);
        return;
      } else if (mapCollection.sourceType === "tdmap") {
 
        var tokne = mapCollection.tokne;
        //添加天地图影像
 
        window.BaseMapLayer = Viewer.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider({
          url: map.urls + tokne,
          layer: "tdtImgLayer",
          style: "default",
          format: "image/jpeg",
          tileMatrixSetID: "GoogleMapsCompatible",
        }))
 
        window.olBaseMapLayer = new TileLayer({
          title: "高德地图",
          source: new XYZ({
            url: map.olUrls + tokne
 
          }),
          zIndex: -1
        });
        window.map.addLayer(window.olBaseMapLayer);
      } else if (mapCollection.sourceType === "gdmap") {
 
        window.BaseMapLayer = Viewer.imageryLayers.addImageryProvider(
          new Cesium.UrlTemplateImageryProvider({
            url: map.urls,
            maximumLevel: 22,
          })
        );
 
        window.olBaseMapLayer = new TileLayer({
          title: "高德地图",
          source: new XYZ({
            url: map.urls,
            wrapX: false
          }),
          zIndex: -1
        });
        window.map.addLayer(window.olBaseMapLayer);
      } else if (mapCollection.sourceType === "localmap") {
        var ulr = map.urls;
        ulr = ulr.replace("{host}", iisHost)
 
        window.BaseMapLayer = Viewer.imageryLayers.addImageryProvider(
          new Cesium.UrlTemplateImageryProvider({
            url: ulr,
            maximumLevel: 22,
          })
        );
 
        window.olBaseMapLayer = new TileLayer({
          title: "高德地图",
          source: new XYZ({
            url: ulr,
            wrapX: false
          }),
          zIndex: -1
        });
        window.map.addLayer(window.olBaseMapLayer);
      }
      Viewer.imageryLayers.lowerToBottom(window.BaseMapLayer);//将图层移到最底层
      Viewer.imageryLayers.raise(window.BaseMapLayer);//将图层移到最底层
 
      if (is_production) {
        Viewer.imageryLayers.raise(window.BaseMapLayer);//将图层上移一层
      }
    },
    // 添加数据
    addData() {
      if (this.data.urls && this.data.sourceType) {
        let data = {
          id: window.sgworld.Core.getuid(),
          ...this.data,
          Level: [0, 26],
        };
        if (data.sourceType === "tdmap") {
          data.urls += "&tk=" + this.tokne;
        } else if (data.sourceType === "bdmap") {
          data.style = this.mapCollection.style;
        }
        if (this.mapCollection.GCJ02) {
          data.GCJ02 = true;
        }
 
        data.item = window.BaseMapLayer;
        window.BaseMapLayer = undefined;
 
        this.$emit("success", data);
        this.close(false, false);
      } else {
        this.$message("请选择地图");
      }
    },
  },
};
</script>
 
<style scoped lang="less">
/deep/.el-card__body {
  padding: 0px !important;
}
.map {
  display: inline-block;
  cursor: pointer;
  margin: 5px;
  text-align: center;
 
  .el-image {
    border: 2px solid #fff;
    border-radius: 4px;
  }
}
.boxCard {
  margin-bottom: 5px;
}
</style>