管道基础大数据平台系统开发-【前端】-新系統界面
13693261870
2024-02-04 d91f0dfcd2ef95fb3624d94ade24fe69a9169a58
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
<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>
    </div>
    </el-form>
  </Popup>
</template>
 
<script>
import Popup from "./Popup";
import TileLayer from "ol/layer/Tile"
import XYZ from "ol/source/XYZ"
// 影像图层
import mapLayers from "./layer";
export default {
  name: "addOnlineOlMap",
  components: {
    Popup,
  },
  mixins: [],
  data() {
    return {
      title: "2D在线地图",
      left: undefined,
      tokne: "",
      data: {
        id: "",
        sourceType: "",
        name: "",
        urls: "",
        layer: "",
        alpha: 1,
        maximumLevel: 26,
        zIndex: undefined,
      },
      mapCollection: undefined,
      mapList: mapLayers,
    };
  },
  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.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.olBaseMapLayer = new TileLayer({
          title: "高德地图",
          source: new XYZ({
            url: map.olUrls + tokne
 
          }),
          zIndex: -1
        });
        window.map.addLayer(window.olBaseMapLayer);
      } else if (mapCollection.sourceType === "gdmap") {
 
     
        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.olBaseMapLayer = new TileLayer({
          title: "高德地图",
          source: new XYZ({
            url: ulr,
            wrapX: false
          }),
          zIndex: -1
        });
        window.map.addLayer(window.olBaseMapLayer);
      }
    
    },
    // 添加数据
    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>