surprise
2024-04-17 f560ccccd3878497339daeee3241a81c263898f7
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
<template>
  <div class="container" id="moved1" v-if="ishow" @mousedown="moved">
    <div class="top">
      <span>模型控制</span>
      <span class="close" @click="showtuli">X</span>
    </div>
    <div class="box">
      <!-- <div>
        <span>上海区域蓝膜</span>
        <el-switch
          v-model="value"
          active-color="#13ce66"
          inactive-color="#ff4949"
        ></el-switch>
      </div> -->
      <div>
        <span>上海白模三维地图</span>
        <el-switch
          v-model="value1"
          active-color="#13ce66"
          inactive-color="#ff4949"
        ></el-switch>
      </div>
      <div>
        <span>上海实景三维地图</span>
        <el-switch
          v-model="value2"
          active-color="#13ce66"
          inactive-color="#ff4949"
        ></el-switch>
      </div>
      <div>
        <span>广州精模三维地图</span>
        <el-switch
          v-model="value6"
          active-color="#13ce66"
          inactive-color="#ff4949"
        ></el-switch>
      </div>
      <div>
        <span>广州实景三维地图</span>
        <el-switch
          v-model="value7"
          active-color="#13ce66"
          inactive-color="#ff4949"
        ></el-switch>
      </div>
      <div>
        <span>广州白膜三维地图</span>
        <el-switch
          v-model="value3"
          active-color="#13ce66"
          inactive-color="#ff4949"
        ></el-switch>
      </div>
      <div>
        <span>主要建筑文字标签</span>
        <el-switch
          v-model="value4"
          active-color="#13ce66"
          inactive-color="#ff4949"
        ></el-switch>
      </div>
    </div>
    <div class="bottom">
      <div>
        <span>光照</span>
        <el-switch
          v-model="light"
          active-color="#13ce66"
          inactive-color="#ff4949"
        ></el-switch>
      </div>
    </div>
  </div>
</template>
<script>
import bus from "../../utils/bus";
import { loaddian, loadBaimo } from "../../utils/work";
export default {
  data() {
    return {
      value: false,
      value1: true,
      ishow: false,
      value2: false,
      value3: false,
      value4: true,
      value5: false,
      value6: false,
      light: false,
      value7: false,
      zhuji: false,
      scale: 2.13,
    };
  },
  methods: {
    fly() {
      window.Viewer.camera.flyTo({
        destination: Cesium.Cartesian3.fromDegrees(
          113.32464417912955,
          23.092040136439294,
          4936.892248015968
        ),
        orientation: {
          heading: 0.1349372341578318,
          pitch: -0.82222154573481174,
          roll: 0,
        },
      });
    },
    showtuli() {
      this.ishow = false;
    },
    moved(event) {
      var drag = document.getElementById("moved1");
      // //点击某物体时,用drag对象即可,move和up是全局区域,
      // 也就是整个文档通用,应该使用document对象而不是drag对象(否则,采用drag对象时物体只能往右方或下方移动)
      var event = event || window.event; //兼容IE浏览器
      //    鼠标点击物体那一刻相对于物体左侧边框的距离=点击时的位置相对于浏览器最左边的距离-物体左边框相对于浏览器最左边的距离
      var diffX = event.clientX * this.scale - drag.offsetLeft;
      var diffY = event.clientY * this.scale - drag.offsetTop;
      document.onmousemove = (event) => {
        var event = event || window.event;
        var moveX = event.clientX * this.scale - diffX;
        var moveY = event.clientY * this.scale - diffY;
        if (moveX < 0) {
          moveX = 0;
        } else if (moveX > 2304 * this.scale - drag.offsetWidth) {
          moveX = 2304 * this.scale - drag.offsetWidth;
        }
        if (moveY < 0) {
          moveY = 0;
        } else if (moveY > 4096 * this.scale - drag.offsetHeight) {
          moveY = 4096 * this.scale - drag.offsetHeight;
        }
        drag.style.left = moveX + "px";
        drag.style.top = moveY + "px";
      };
      document.onmouseup = function (event) {
        document.onmousemove = null;
        document.onmouseup = null;
      };
    },
    removeitem() {
      try {
        Viewer.scene.primitives.remove(window.model2.item);
        Viewer.scene.primitives.remove(window.model3.item);
        Viewer.scene.primitives.remove(window.model4.item);
      } catch (e) {}
    },
    //边框的显示隐藏
  },
  mounted() {
    //初始取消光照
    bus.$on("showindex", (e) => {
      if (this.boxindex == e) {
        this.boxindex = 0;
      } else {
        this.boxindex = e;
      }
    });
    bus.$on("ishow", (e) => {
      this.ishow = this.ishow ? false : true;
    });
  },
  watch: {
    value(data){
      if (data) {
        loadBaimo(7)
      }else{
         Viewer.scene.primitives.remove(window.model12.item);
        Viewer.scene.primitives.remove(window.model13.item);
        Viewer.scene.primitives.remove(window.model14.item);
        Viewer.scene.primitives.remove( window.model15.item);
       
      }
    },
    value1(data) {
      if (data) {
         loadBaimo(1)
      }else{
        Viewer.scene.primitives.remove(window.model1.item);
        Viewer.scene.primitives.remove(window.model12.item);
      }
    },
    value2(data) {
      data ? loadBaimo(2) : Viewer.scene.primitives.remove(window.model8.item);
    },
 
    value4(data) {
      if (data) {
        // 上海注记
        let urldian =
          "http://183.162.245.49:8099/geoserver/SHP/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=SHP:SH_POI1&outputFormat=application%2Fjson";
          //广州注记
        let url =
          "http://183.162.245.49:8099/geoserver/SHwuxiandian/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=SHwuxiandian:1GZ_POI&outputFormat=application%2Fjson";
        loaddian(url, "[TE_DESC]", "[height]");
        loaddian(urldian, "[name]", "[Height]");
      }else{
        for (let index = 0; index < window.deleteObj.length; index++) {
          window.deleteObj[index].deleteObject()
          //window.deleteObj[index] =[]
        }
         window.deleteObj=[];
      }
    },
    value6(data) {
      if(data){
        this.fly();
        loadBaimo(4)
      }else{
        Viewer.scene.primitives.remove(window.model9.item);
        Viewer.scene.primitives.remove(window.model10.item);
        Viewer.scene.primitives.remove(window.model11.item);
      }
    },
    value7(data) {
      data ? loadBaimo(5) : this.removeitem();
      data ? this.fly() : "";
    },
    value3(data) {
      data ? loadBaimo(6) : Viewer.scene.primitives.remove(window.model6.item);
      data ? this.fly() : "";
    },
    light(data) {
      window.Viewer.scene.globe.enableLighting = data;
    },
  },
};
</script>
<style  scoped>
.top {
  width: 94%;
  height: 100px;
  margin: 0 auto;
  border-bottom: 2px solid #fff;
  color: #fff;
}
.top > span {
  display: inline-block;
  margin: 10px 20px;
  font-size: 40px;
  letter-spacing: 5px;
  font-weight: 300;
  line-height: 80px;
  margin-left: 40px;
  font-size: 42px;
  font-family: Source Han Sans SC;
  font-weight: bold;
  color: #ffffff;
}
.container {
  width: 700px;
  position: absolute;
  right: 340px;
  top: 180px;
  z-index: 50;
  background: url(~@/assets/image/test/22.png);
  background-position: center;
  background-size: 100% 100%;
  cursor: move;
}
.box {
  width: 96%;
  font-weight: bold;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  flex-direction: column;
  -ms-flex-pack: distribute;
  align-items: center;
  border-bottom: 2px solid #fff;
  margin: 30px auto;
}
.container >>> .el-switch__core {
  width: 140px !important;
  height: 50px;
  margin-left: 30px;
  border-radius: 28px;
}
.container >>> .el-switch__core:after {
  width: 48px;
  height: 48px;
  margin-left: 0px;
  top: 0px;
}
.container >>> .el-switch.is-checked .el-switch__core::after {
  margin-left: -50px !important;
}
.box > div {
  width: 100%;
  height: 70px;
  font-size: 40px;
  line-height: 70px;
  margin-top: 20px;
  color: #fff;
  margin-left: 55px;
}
.box > div > span {
  display: inline-block;
  width: 50%;
  text-align: center;
}
.box > div:nth-last-child(1){
  margin-bottom: 30px;
}
.bottom{
  width: 100%;
  margin-bottom: 20px;
}
.bottom > div {
  font-weight: bold;
  width: 100%;
  font-size: 40px;
  line-height: 70px;
  margin-top: 20px;
  color: #fff;
  margin-left: 55px;
}
.bottom > div:nth-last-child(1) {
  margin-bottom: 40px;
}
.bottom > div > span {
  display: inline-block;
  width: 50%;
  text-align: center;
}
.close {
  position: absolute;
  right: 20px;
  top: 0px;
  cursor: pointer;
}
/* .container>div{
width: 100%;
height: 20%;
border: 1px solid #000;
} */
</style>