shuishen
2022-04-29 443c649303cc275f4ff07b3d2f5e589047f8054d
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
/* * @Author: Morpheus * @Name: 地图测距 * @Date: 2021-11-13 16:04:27 * @Last
Modified by: Morpheus * @Last Modified time: 2022-02-15 14:28:44 */
 
<template>
    <public-box class="technique-box">
        <template slot="public-box-header">
            <div class="title">
                <span>turf计算</span>
            </div>
            <img class="close deblurring" src="/img/navicon/close.png" alt @click="closeModel" />
        </template>
        <template slot="public-box-content">
            <ul>
                <li>
                    点位缓冲
                    <el-switch
                        v-model="pointShow"
                        :active-value="true"
                        :inactive-value="false"
                        @change="pointChange"
                    ></el-switch>
                </li>
                <li>
                    线缓冲
                    <el-switch
                        v-model="plineShow"
                        :active-value="true"
                        :inactive-value="false"
                        @change="plineChange"
                    ></el-switch>
                </li>
                <li>
                    面缓冲
                    <el-switch
                        v-model="regionShow"
                        :active-value="true"
                        :inactive-value="false"
                        @change="regionChange"
                    ></el-switch>
                </li>
            </ul>
        </template>
    </public-box>
</template>
 
<script>
 
let pointTrufLayer = null
let pointTrufPolygon = null
let pointTrufPoint = null
 
let plineTrufLayer = null
let plineTrufPolygon = null
let plineTrufPline = null
 
let regionTrufLayer = null
let regionTrufRegion = null
let regionTrufPolygon = null
 
export default {
    data () {
        return {
            pointShow: false,
            plineShow: false,
            regionShow: false
        }
    },
    mounted () {
    },
    methods: {
        closeModel () {
            this.$router.push('/pcLayout/default')
        },
        loadPoint () {
            pointTrufLayer = new global.DC.VectorLayer('pointTrufLayer')
            global.viewer.addLayer(pointTrufLayer)
            pointTrufPoint = new global.DC.Point('114.0415,27.6299,150')
            pointTrufLayer.addOverlay(pointTrufPoint)
            const coords = global.DC.GeoTools.pointBuffer('114.0415,27.6299', 50)
            pointTrufPolygon = new global.DC.Polygon(coords)
            pointTrufPolygon.setStyle({
                material: global.DC.Color.RED.withAlpha(0.4)
            })
            pointTrufLayer.addOverlay(pointTrufPolygon)
            global.viewer.flyTo(pointTrufLayer)
        },
        removePoint () {
            pointTrufPoint != null && pointTrufLayer.removeOverlay(pointTrufPoint)
            pointTrufPolygon != null && pointTrufLayer.removeOverlay(pointTrufPolygon)
            pointTrufLayer != null && global.viewer.removeLayer(pointTrufLayer)
            pointTrufPoint = null
            pointTrufPolygon = null
            pointTrufLayer = null
        },
        pointChange (e) {
            if (e) {
                this.loadPoint()
            } else {
                this.removePoint()
            }
        },
        loadPline () {
            plineTrufLayer = new global.DC.VectorLayer('plineTrufLayer')
            global.viewer.addLayer(plineTrufLayer)
            plineTrufPline = new global.DC.Polyline('114.0411,27.62997062,152;114.0418,27.62997062,152')
            plineTrufPline.setStyle({
                width: 2,
                material: global.DC.Color.YELLOW,
                zIndex: 1
            })
            plineTrufLayer.addOverlay(plineTrufPline)
            const coords = global.DC.GeoTools.polylineBuffer('114.0411,27.62997062;114.0418,27.62997062', 50)
            plineTrufPolygon = new global.DC.Polygon(coords)
            plineTrufPolygon.setStyle({
                material: global.DC.Color.RED.withAlpha(0.4)
            })
            plineTrufLayer.addOverlay(plineTrufPolygon)
            global.viewer.flyTo(plineTrufLayer)
        },
        removePline () {
            plineTrufPline != null && plineTrufLayer.removeOverlay(plineTrufPline)
            plineTrufPolygon != null && plineTrufLayer.removeOverlay(plineTrufPolygon)
            plineTrufLayer != null && global.viewer.removeLayer(plineTrufLayer)
            plineTrufPline = null
            plineTrufPolygon = null
            plineTrufLayer = null
        },
        plineChange (e) {
            if (e) {
                this.loadPline()
            } else {
                this.removePline()
            }
        },
        loadRegion () {
            regionTrufLayer = new global.DC.VectorLayer('regionTrufLayer')
            global.viewer.addLayer(regionTrufLayer)
            regionTrufRegion = new global.DC.Polygon('114.0410,27.6299,152;114.0418,27.6312,152;114.0426,27.6299,152')
            regionTrufRegion.setStyle({
                zIndex: 1,
                material: global.DC.Color.YELLOW
            })
            regionTrufLayer.addOverlay(regionTrufRegion)
            const coords = global.DC.GeoTools.polygonBuffer('114.0410,27.6299;114.0415,27.6312;114.0426,27.6299', 150)
            regionTrufPolygon = new global.DC.Polygon(coords)
            regionTrufPolygon.setStyle({
                material: global.DC.Color.RED.withAlpha(0.4)
            })
            regionTrufLayer.addOverlay(regionTrufPolygon)
            global.viewer.flyTo(regionTrufLayer)
        },
        removeRegion () {
            regionTrufRegion != null && regionTrufLayer.removeOverlay(regionTrufRegion)
            regionTrufPolygon != null && regionTrufLayer.removeOverlay(regionTrufPolygon)
            regionTrufLayer != null && global.viewer.removeLayer(regionTrufLayer)
            regionTrufRegion = null
            regionTrufPolygon = null
            regionTrufLayer = null
        },
        regionChange (e) {
            if (e) {
                this.loadRegion()
            } else {
                this.removeRegion()
            }
        }
    },
    destroyed () {
        this.removePoint()
        this.removePline()
        this.removeRegion()
    }
}
</script>
 
<style lang="sass" scoped>
.move
    cursor: move
</style>