北京经济技术开发区经开区虚拟城市项目-【前端】-移动端Web
少年
2024-02-06 0350f3c02209ee8b62f818810eaa663289158843
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
<template>
  <div class="bottom" id="bottom">
    <div class="mapTools" v-show="show">
      <div class="mapTool" v-show="test.fwval">
        <el-button class="tool-rotate" @click="zoomIn" title="放大">
          <img src="../../../static/img/image/zoomIn.png" />
        </el-button>
      </div>
      <div class="mapTool" v-show="test.fwval">
        <el-button class="tool-rotate" @click="zoomOut" title="缩小">
          <img src="../../../static/img/image/zoomOut.png" />
        </el-button>
      </div>
    </div>
  </div>
</template>
 
<style scoped>
.bottom {
  position: absolute;
  bottom: 0.4rem;
  height: 0.76rem;
  right: 0.4rem;
}
.mapModeControl {
  position: absolute;
  right: 0.05rem;
  background: rgba(90, 90, 90, 0.5);
  bottom: 0.05rem;
  height: 0.76rem;
  width: 1.03rem;
  transition: all 1s;
}
.bottom .mapModeControl:hover {
  transition: all 0.6s;
  -webkit-transition: all 0.6s;
  width: 3.2rem;
}
.mapMode {
  display: inline-block;
}
.mapMode dl {
  width: 0.88rem;
  height: 0.6rem;
  border: 1px solid #494949;
  cursor: pointer;
  margin: 0.08rem;
}
 
.mapMode dl:hover {
  border-color: #0553b4;
}
 
.mapMode dl {
  position: relative;
}
#history {
  background: url(../../../static/img/1.png) no-repeat;
}
#mode-3d {
  background: url(../../../static/img/2.png) no-repeat;
}
#mode-2d {
  background: url(../../../static/img/4.png) no-repeat;
}
.mapMode dt {
  width: 100%;
  height: 0.2rem;
  line-height: 0.2rem;
  position: absolute;
  left: 0;
  bottom: 0px;
  font-size: 0.12rem;
  text-align: center;
  color: #fff;
  text-shadow: 1px 1px 2px #000;
  background: rgba(0, 0, 0, 0.5);
}
.mapModeActive {
  background: rgba(1, 37, 80, 0.5) !important;
}
 
.mapTools {
  position: absolute;
  /* bottom: 2rem; */
  bottom: 0.2rem;
  /* right: 0.1rem; */
}
.mapTool {
  margin: 0.1rem 0;
}
.mapTool .el-button {
  padding: 0 !important;
  font-size: 0.24rem;
  border: unset;
  float: unset;
  display: block;
  background: rgba(18, 126, 255, 1);
}
 
/* .button-group-vertical {
  text-align: center;
  position: relative;
} */
.fgx {
  position: absolute;
  width: 80%;
  height: 1px;
  height: 1px;
  border: 1px solid #dcdfe6;
  z-index: 999;
  margin: 0 10%;
}
/* .button-group-vertical .el-button-group > .el-button:first-child {
  border-top-right-radius: 0.04rem !important;
  border-bottom-left-radius: 0px !important;
}
.button-group-vertical .el-button-group > .el-button:last-child {
  border-top-right-radius: 0;
  border-bottom-left-radius: 0.04rem !important;
} */
.mapTool img {
  width: 24px;
  margin: 3px;
  /* height: 0.4rem; */
}
</style>
    
<script>
import Bus from "../../js/bus.js";
export default {
  props: ["test"],
  data() {
    return {
      show: true,
      parentdata: {
        fwval: false,
        zbzval: false,
        qpval: false,
        zymlval: false,
        kjcxval: false,
        dxmsval: false,
        snmsval: false,
        ssval: false,
      },
      clickIndex: 0,
      // isShowHistory: false,
      camera: {
        position: [116.52217697339846, 39.75979421847914, 17045.47005612415],
        orientation: {
          heading: 0,
          pitch: -90,
          roll: 0,
        },
      },
      modes: [
        {
          id: "mode-3d",
          name: "3D",
          mode: 3,
        },
        {
          id: "mode-2d",
          name: "2D",
          mode: 2,
        },
      ],
    };
  },
  mounted() {
    Bus.$on("myMsg", (myMsg) => {
      this.show = myMsg;
    });
  },
  methods: {
    zoomIn() {
      const view = window.map.getView();
      const zoom = view.getZoom();
 
      map.getView().animate({
        // 只设置需要的属性即可
        center: window.map.getView().getCenter(), // 中心点
        zoom: zoom + 1, // 缩放级别
        rotation: undefined, // 缩放完成view视图旋转弧度
        duration: 1000, // 缩放持续时间,默认不需要设置
      });
    },
    zoomOut() {
      const view = window.map.getView();
      const zoom = view.getZoom();
 
      map.getView().animate({
        // 只设置需要的属性即可
        center: window.map.getView().getCenter(), // 中心点
        zoom: zoom - 1, // 缩放级别
        rotation: undefined, // 缩放完成view视图旋转弧度
        duration: 1000, // 缩放持续时间,默认不需要设置
      });
    },
  },
};
</script>