北京经济技术开发区经开区虚拟城市项目-【前端】-移动端Web
111
少年
2024-02-07 f7ab8838f095134c65d2628fe54a6fb8c5df146e
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
<template>
    <div class="collectionPanel">
        <div class="menutop">
            <div class="menuback" @click="back">
                <i class="el-icon-arrow-left"></i><span>返回</span>
            </div>
            <div class="menutitle">位置</div>
        </div>
        <div class="collectionContainer">
            <!-- <el-tabs type="border-card">
                <el-tab-pane label="收藏" v-if="dataSc.length !== 0">
                    <div class="collectionItem" v-for="(item, index) in dataSc" :key="index"
                        @click="goScPoint(item.position)">
                        <i class="el-icon-star-off"></i>
                        {{ item.name }}
                        <span style="float: right; margin-right: 0.2rem" v-on:click.stop="deleteSc(index)"><i
                                class="el-icon-delete"></i></span>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="收藏" v-else>
                    <div class="collectionItem" style="text-align: center">暂无数据!</div>
                </el-tab-pane>
                <el-tab-pane label="定位">
                    <div class="collectionItem" v-for="(item, index) in dataPosition" :key="index" @click="flyTo(item.geo)">
                        <i class="el-icon-location-outline"></i>{{ item.name }}
                    </div>
                </el-tab-pane>
            </el-tabs> -->
            <el-radio-group v-model="selectedType">
                <el-radio-button label="sc">收藏</el-radio-button>
                <el-radio-button label="dw">定位</el-radio-button>
            </el-radio-group>
 
            <div class="scContainer" v-if="selectedType == 'sc'">
                <div v-if="dataSc.length !== 0">
                    <div class="title"><span>收藏列表</span></div>
                    <div class="collectionItem" v-for="(item, index) in dataSc" :key="index"
                        @click="goScPoint(item.position)">
                        <img src="@/assets/img/collection/sc.png" />
                        <span>{{ item.name }}</span>
                        <span style="float: right; margin-right: 0.2rem" v-on:click.stop="deleteSc(index)"><i
                                class="el-icon-delete"></i></span>
                    </div>
                </div>
                <div class="emptyContainer" v-else>
                    <span>暂无数据!</span>
                    <img src="@/assets/img/collection/empty.png" />
                </div>
            </div>
            <div class="dwContainer" v-else>
                <div class="title"><span>定位列表</span></div>
                <div class="collectionItem" v-for="(item, index) in dataPosition" :key="index" @click="flyTo(item.geo)">
                    <img src="@/assets/img/collection/scdw.png" /><span>{{ item.name }}</span>
                </div>
            </div>
        </div>
    </div>
</template>
 
<script>
window.flyPoint = null;
import store from "@/utils/store2.js";
import { createPointMarker,flyToPoint } from '@/utils/map2.js'
export default {
    name: 'CollectionPanel',
    data() {
        return {
            dataSc: [],//收藏数据
            dataPosition: [
                { name: "亦庄文化园", geo: "POINT(116.497869 39.813206)" },
                { name: "北京经开壹中心", geo: "POINT(116.562533 39.78587)" },
                { name: "汇通大厦", geo: "POINT(116.508368 39.79346)" },
            ],//定位数据
            selectedType: 'sc'
        }
    },
    mounted() {
        this.dataSc = window.locations || [];
    },
    methods: {
        goScPoint(position) {
            store.setLocationCollectionShow(false);
            sgworld.Viewer.camera.flyTo({
                destination: position.destination,
                duration: 3,
                maximumHeight: 20000,
                pitchAdjustHeight: 1500,
                orientation: {
                    heading: position.orientation.heading,
                    pitch: position.orientation.pitch,
                    roll: position.orientation.roll,
                },
            });
        },
        flyTo(geo) {
            store.setLocationCollectionShow(false);
            let arr = geo.substring(6, geo.length - 1).split(' ');
            let coords = [Number(arr[0]), Number(arr[1])]
            flyToPoint(coords)
            let layer = createPointMarker(coords, null);
            window.mapapi.addLayer(layer)
 
 
            // let degrees = this.getPosition(geo);
            // flyPoint && Viewer.entities.remove(flyPoint);
            // sgworld.Navigate.flyToPointsInterest({
            //     destination: Cesium.Cartesian3.fromDegrees(
            //         degrees[0],
            //         degrees[1],
            //         3000
            //     ),
            // });
            // flyPoint = Viewer.entities.add({
            //     position: Cesium.Cartesian3.fromDegrees(degrees[0], degrees[1]),
            //     billboard: {
            //         verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
            //         scale: 1,
            //         image: window.SmartEarthRootUrl + "/Workers/image/mark.png",
            //         heightReference: 1,
            //         disableDepthTestDistance: Number.POSITIVE_INFINITY,
            //     },
            // });
        },
        deleteSc(index) {
            this.$confirm("删除该收藏点, 是否继续?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.dataSc.splice(index, 1);
                    // 把位置信息添加到缓存中
                    window.setLocations(this.dataSc);
                    // 从缓存中取出当前所有位置信息
                    this.dataSc = window.locations;
                    this.$message({ message: "删除成功!", duration: 1500, type: "success" });
                })
                .catch(() => {
                    this.$message({ type: "info", duration: 1500, message: "已取消删除" });
                });
        },
        getPosition(geo) {
            let p = geo && geo.replace("POINT(", "").replace(")", "");
            return p.split(" ");
        },
        back() {
            store.setLocationCollectionShow(false);
        }
    },
}
</script>
 
<style scoped>
.collectionPanel {
    position: absolute;
    color: black;
    width: 100%;
    height: 100%;
    background-color: white;
    z-index: 1001;
}
 
.collectionContainer {
    margin-top: 0.2rem;
    padding: 0.1rem;
}
 
.emptyContainer {
    margin-top: 0.2rem;
    text-align: center;
}
 
.emptyContainer img {
    width: 100%;
}
 
.scContainer {
    margin-top: 0.2rem;
}
 
.dwContainer {
    margin-top: 0.2rem;
}
 
.el-tabs--border-card /deep/ .el-tabs__header {
    background-color: lightgray;
    border-radius: 0.05rem;
}
 
.el-tabs {
    position: absolute;
    height: 80%;
    width: 95%;
    margin-left: 2.5%;
    border-radius: 0.05rem;
}
 
.el-tabs /deep/ .el-tabs__nav-wrap {
    border-top-left-radius: 0.05rem;
    border-top-right-radius: 0.05rem;
}
 
.el-tabs /deep/ .el-tabs__item {
    padding: 0 0.2rem;
    height: 0.3rem;
    line-height: 0.3rem;
    font-size: 0.14rem;
}
 
.el-tabs /deep/ .el-tabs__content {
    height: 90%;
    overflow: scroll;
}
 
.title {
    height: 0.4rem;
    line-height: 0.4rem;
    font-size: 16px;
    border-bottom: 1px solid #E5E5E6;
}
 
.title span {
    padding-left: 10px;
}
 
.collectionItem {
    /* font-size: 0.16rem; */
    /* background-color: rgb(228, 227, 227); */
    /* margin-bottom: 0.1rem; */
    height: 0.4rem;
    line-height: 0.4rem;
    /* border-radius: 0.05rem; */
    padding-left: 0.1rem;
    border-bottom: 1px solid #E5E5E6;
}
 
.collectionItem img {
    width: 0.16rem;
}
 
.collectionItem span {
    padding-left: 10px;
}
 
/deep/ .el-radio-button .el-radio-button__inner {
    width: 184px !important;
}
</style>