87f17efe by 刘远

Merge remote-tracking branch 'origin/master'

2 parents 5cce70a9 33dfa599
1 <template> 1 <template>
2 <div class="home"> 2 <div class="home">
3 <div id="cesiumContainer" style="width:100%;height:100%;"></div> 3 <div id="cesiumContainer" style="width:100%;height:100%;"></div>
4 <!-- <el-button @click="testfun" class="testbtn"></el-button> -->
5 <el-select @change="selectChanged" class="testbtn">
6 <el-option v-for="item in devTypes" :key="item" :label="item" :value="item"></el-option>
7 </el-select>
4 </div> 8 </div>
5 </template> 9 </template>
6 <script> 10 <script>
7 11
12 import tool from "../assets/js/map/tool";
13
8 export default { 14 export default {
9 components: {}, 15 components: {},
10 data() { 16 data() {
11 return { 17 return {
12 viewer: undefined, 18 viewer: undefined,
13 entity: undefined, 19 entity: undefined,
20 devTypes: ['point', 'polyline', 'polygon']
14 } 21 }
15 }, 22 },
16 mounted() { 23 mounted() {
24 // ***********************************初始化地图********************************************
17 Cesium.Ion.defaultAccessToken = this.config.mapToken; 25 Cesium.Ion.defaultAccessToken = this.config.mapToken;
18 this.viewer = new Cesium.Viewer('cesiumContainer', { 26 this.viewer = new Cesium.Viewer('cesiumContainer', {
19 geocoder:true, 27 geocoder:true,
20 timeline:false 28 timeline:false,
29 imageryProvider: new Cesium.UrlTemplateImageryProvider({
30 url: 'https://mt1.google.cn/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}&s=Gali'
31 })
21 }); 32 });
22 33
23 this.viewer.imageryLayers.addImageryProvider(
24 new Cesium.UrlTemplateImageryProvider({
25 url: "https://mt1.google.cn/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}&s=Gali"
26 }));
27
28 34
35 // ***********************************倾斜摄影加载********************************************
29 let tileset = new Cesium.Cesium3DTileset({ 36 let tileset = new Cesium.Cesium3DTileset({
30 url : 'http://localhost:9000/model/e44fe150d09b11eaabec1d24e8548b3a/tileset.json', 37 url : 'http://localhost:9000/model/e44fe150d09b11eaabec1d24e8548b3a/tileset.json',
31 skipLevelOfDetail : true, 38 skipLevelOfDetail : true,
...@@ -48,17 +55,64 @@ ...@@ -48,17 +55,64 @@
48 }); 55 });
49 56
50 57
58 // ***********************************水位********************************************
59 setTimeout(() => {
60 var positions = [
61 101.67468055555556, 36.54803611111111, 101.66768055555556, 36.55503611111111,
62 101.65068055555556, 36.56403611111111, 101.67468055555556, 36.54803611111111
63 ], waterHeight = 0,
64 entity = this.viewer.entities.add({
65 polygon: {
66 // hierarchy: Cesium.Cartesian3.fromDegreesArray(positions),
67 hierarchy: [
68 new Cesium.Cartesian3(-1036931.6607544887,5024383.265188632,3776882.2179509313),
69 new Cesium.Cartesian3(-1037689.1138430117,5023931.060901769,3777273.070930741),
70 new Cesium.Cartesian3(-1038031.7922958151,5024211.372681549,3776809.176021656),
71 new Cesium.Cartesian3(-1037502.0690553376,5024558.056853799,3776495.627250331)
72 ],
73 material: Cesium.Color.RED.withAlpha(0.5),
74 extrudedHeight: new Cesium.CallbackProperty(function () {
75 return waterHeight;
76 })
77 }
78 });
79 // this.viewer.zoomTo(entity);
80 this.viewer.clock.onTick.addEventListener(function () {
81 if (waterHeight > 250){
82 waterHeight = 0;
83 }
84 waterHeight += 0.1;
85 })
51 86
87 }, 30000);
88
52 89
53 90 // ********************************Draw********************************************
91 this.draw = new tool.attributes.drawPolt({
92 viewer: this.viewer
93 })
54 }, 94 },
55 methods: { 95 methods: {
56 96 selectChanged(e) {
97 this.draw.type[e] || (this.draw.type[e] = new tool.attributes[e]({viewer: this.viewer}));
98 this.draw.type[e].startCreate();
99 console.log(this.draw.type[e]);
100 },
101 drawShape() {
102
103 }
57 } 104 }
58 } 105 }
59 </script> 106 </script>
60 107
61 <style scoped lang="scss"> 108 <style scoped>
62 109
110 .testbtn {
111 position: absolute;
112 top: 100px;
113 left: 100px;
114 width: 100px;
115 height: 30px;
116 }
63 117
64 </style> 118 </style>
...\ No newline at end of file ...\ No newline at end of file
......