mapTools.vue
20.4 KB
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
<template>
<div class="tools">
<ul>
<li>
<i class="iconfont iconhangzhengqudaohang"></i>
<span>行政区导航</span>
</li>
<li>
<i class="iconfont iconkongjianchaxun"></i>
<span>空间查询</span>
</li>
<li>
<i class="iconfont iconzuobiaodingwei"></i>
<span>定位</span>
</li>
<li>
<i class="iconfont iconduopingduibi"></i>
<span>多屏对比</span>
</li>
<li @click="fullMap">
<i class="iconfont iconquantu"></i>
<span>全图</span>
</li>
<li @click="measureMent('distance')">
<i class="iconfont iconceju"></i>
<span>测距</span>
</li>
<li @click="measureMent('area')">
<i class="iconfont iconcemianji"></i>
<span>测面</span>
</li>
<li @click="zoomOut">
<i class="iconfont iconlakuangfangda"></i>
<span>放大</span>
</li>
<li @click="zoomIn">
<i class="iconfont iconlakuangsuoxiao"></i>
<span>缩小</span>
</li>
<li @click="info">
<i class="iconfont iconxinxi"></i>
<span>识别</span>
</li>
<li @click="clear">
<i class="iconfont iconqingchu"></i>
<span>清除</span>
</li>
</ul>
<!-- <el-button-group>
<el-button type="primary" title="全图" icon="iconfont iconquantu" @click="fullMap"></el-button>
<el-button type="primary" title="测面" icon="iconfont iconcemianji" @click="measureMent('area')"></el-button>
<el-button type="primary" title="测距" icon="iconfont iconceju" @click="measureMent('distance')"></el-button>
<el-button type="primary" title="放大" icon="iconfont iconlakuangfangda" @click="zoomOut"></el-button>
<el-button type="primary" title="缩小" icon="iconfont iconlakuangsuoxiao" @click="zoomIn"></el-button>
<el-button type="primary" title="点选" icon="iconfont iconchaxunshuxing" @click="info"></el-button>
<el-button type="primary" title="缓冲区分析" icon="iconfont iconqingchu" @click="bufferAnalysis"></el-button>
<el-button type="primary" title="清除" icon="iconfont iconqingchu" @click="clear"></el-button>
</el-button-group> -->
<div class="bufferDialog" v-show="bufferDialog">
<el-tabs v-model="activeName" type="card" @tab-click="tabClick">
<el-tab-pane label="绘制范围" name="hzfw">
<div class="contentItem">
<span>绘制范围:</span>
<div class="drawTypes">
<el-button type="text" @click="bufferParams.drawType = 'point'">点</el-button>
<el-button type="text" @click="bufferParams.drawType = 'circle'">圆</el-button>
<el-button type="text" @click="bufferParams.drawType = 'polygon'">任意多边形</el-button>
</div>
</div>
<div class="contentItem">
<span>缓冲距离:</span>
<el-input-number :min="0" v-model="bufferParams.distance" size="small"></el-input-number> 米
</div>
<div class="contentItem">
<span>图层选择:</span>
<el-select size="small" multiple v-model="bufferParams.layerId">
<el-option
v-for="item in bufferLayers"
:key="item.id"
:label="item.layerName"
:value="item.id">
</el-option>
</el-select>
</div>
<div class="buttonDiv">
<el-button size="small" type="primary" @click="toIdentity">确定</el-button>
<el-button size="small" @click="resetBufferParams">重置</el-button>
</div>
</el-tab-pane>
<el-tab-pane label="导入范围" name="drfw">
<div class="contentItem">
<span>绘制范围:</span>
<div class="drawTypes">
<i class="el-icon-plus" @click="openImportDialog"></i>
</div>
</div>
<div class="contentItem">
<span>缓冲距离:</span>
<el-input-number :min="0" v-model="bufferParams.distance" size="small"></el-input-number> 米
</div>
<div class="contentItem">
<span>图层选择:</span>
<el-select size="small" multiple v-model="bufferParams.layerId">
<el-option
v-for="item in bufferLayers"
:key="item.id"
:label="item.layerName"
:value="item.id">
</el-option>
</el-select>
</div>
<div class="buttonDiv">
<el-button size="small" type="primary" @click="importIdentity">确定</el-button>
<el-button size="small" @click="resetBufferParams">重置</el-button>
</div>
</el-tab-pane>
<el-tab-pane label="选择范围" name="xzfw">
<div class="contentItem">
<!--地籍区/地籍子区-->
<span>选择范围:</span>
<el-select v-model="bufferParams.selectDjq" filterable size="small" placeholder="请选择地籍区" @change="getDjzqList">
<el-option
v-for="(item,index) in djqList"
:key="index"
:label="item.mc"
:value="item.dm">
</el-option>
</el-select>
<el-select v-model="bufferParams.selectDjzq" filterable size="small" placeholder="请选择地籍子区">
<el-option
v-for="(item,index) in djzqList"
:key="index"
:label="item.mc"
:value="item.dm">
</el-option>
</el-select>
</div>
<div class="contentItem">
<span>缓冲距离:</span>
<el-input-number :min="0" v-model="bufferParams.distance" size="small"></el-input-number> 米
</div>
<div class="contentItem">
<span>图层选择:</span>
<el-select size="small" multiple v-model="bufferParams.layerId">
<el-option
v-for="item in bufferLayers"
:key="item.id"
:label="item.layerName"
:value="item.id">
</el-option>
</el-select>
</div>
<div class="buttonDiv">
<el-button size="small" type="primary" @click="toFwIdentity">确定</el-button>
<el-button size="small" @click="resetBufferParams">重置</el-button>
</div>
</el-tab-pane>
</el-tabs>
</div>
<el-dialog title="图形导入" :visible.sync="importDialog"
width="30%">
<import-geometry @setGeometry="setGeometry"></import-geometry>
</el-dialog>
</div>
</template>
<script>
import {maps} from '@/libs/map/mapUtils'
import draw from '@/libs/map/draw'
import identifyUtils from '@/libs/map/IdentifyUtils'
import measure from '@/libs/map/measure'
import mapTools from "./js/mapTools";
import {loadModules} from "esri-loader"
import importGeometry from './importGeometry'
export default {
props:{
viewId:{
type:String,
default:"mainView"
}
},
mixins:[draw,identifyUtils,measure,mapTools],
components:{
importGeometry
},
data(){
return{
url:"http://192.168.2.201:6080/arcgis/rest/services/%E4%BA%92%E8%81%94%E7%BD%91%E5%8A%A0%E4%B8%8D%E5%8A%A8%E4%BA%A7/XA_%E4%B8%8D%E5%8A%A8%E4%BA%A7/MapServer",
selectResLayerId:"",
features:[],
resultLayers:[],
results:[],
bufferParams:{
drawType:"",
distance:0,
layerId:[],
impotGeo:null,
selectDjq:"",
selectDjzq:""
},
activeName:'hzfw',
bufferLayers:[{
layerName:"宗地",
id:"8"
},
{
layerName:"自然幢",
id:"10"
},
{
layerName:"构筑物",
id:"2"
},
{
layerName:"林权",
id:"5"
},
{
layerName:"宗海",
id:"9"
}],
bufferDialog:false,
djqList:[],
djzqList:[],
importDialog:false,
importGeo:""
}
},
methods:{
fullMap(){
var view = maps[this.viewId];
view.zoom = 10;
view.center = [108.95,34.27]
},
measureMent(type){
this.measure(this.viewId,type);
},
clearHeightLayer(){
},
clear(){
this.measure(this.viewId,null);
this.$parent.closeResultDialog();
},
info(){
var view = maps[this.viewId];
var self = this;
this.initDraw("point",this.viewId,null,function(geo){
self.identify(self.url,[8,10],geo,function(res){
var resultes = res.results;
if(resultes && resultes.length > 0){
self.$parent.delIdentifyData(resultes);
self.$parent.dialogVisible = true;
}else{
self.$message.success("暂无数据!!!");
}
},true,'all',3,view.extent);
});
},
zoomOut(){
var view = maps[this.viewId];
this.initDraw("rectangle",this.viewId,null,function(geo){
view.extent = geo.extent;
});
},
zoomIn(){
var view = maps[this.viewId];
this.initDraw("rectangle",this.viewId,null,function(geo){
var dWidth, dHeight, dXmin, dYmin, dXmax, dYmax;
dWidth = view.extent.width * view.extent.width / geo.extent.width;
dHeight = view.extent.height * view.extent.height / geo.extent.height;
dXmin = view.extent.xmin - ((geo.extent.xmin - view.extent.xmin) * view.extent.width / geo.extent.width);
dYmin = view.extent.ymin - ((geo.extent.ymin - view.extent.ymin) * view.extent.height / geo.extent.height);
dXmax = dXmin + dWidth;
dYmax = dYmin + dHeight;
//pEnv.PutCoords(dXmin, dYmin, dXmax, dYmax);
loadModules(["esri/geometry/Extent"]).then(([Extent]) => {
view.extent = new Extent({
xmin: dXmin,
ymin: dYmin,
xmax: dXmax,
ymax: dYmax,
spatialReference: {
wkid: 102100
}
});
}).catch( err => {
throw (err);
})
});
},
//缓冲区分析
bufferAnalysis(){
this.bufferDialog = true;
},
//缓冲区分析执行语句
toIdentity(){
var self = this;
var view = maps[this.viewId];
for(var key in this.bufferParams){
if((key == 'distance' || key == 'layerId' || key == 'drawType')&&!this.bufferParams[key].toString()){
var name = "";
switch (key) {
case 'distance':name = '缓冲距离';break;
case 'layerId':name = '分析图层';break;
case 'drawType':name = '绘制类型';break;
}
key == 'distance'?this.$message.warning("请输入"+name):this.$message.warning("请选择"+name);
return;
}
}
this.initDraw(this.bufferParams.drawType,this.viewId,null,function(geo){
self.createBuffer(geo,self.bufferParams.distance,self.viewId,function (bufGeo) {
self.identify(self.url,self.bufferParams.layerId,bufGeo,function(res){
var resultes = res.results;
if(resultes && resultes.length > 0){
self.$parent.delIdentifyData(resultes);
self.$parent.dialogVisible = true;
}else{
self.$message.success("暂无数据!!!");
}
},true,'all',3,view.extent);
})
})
},
toFwIdentity(){
var self = this;
var view = maps[this.viewId];
for(var key in this.bufferParams){
if((key == 'distance' || key == 'layerId' || key == 'selectDjq')&&!this.bufferParams[key].toString()){
var name = "";
switch (key) {
case 'distance':name = '缓冲距离';break;
case 'layerId':name = '分析图层';break;
case 'selectDjq':name = '地籍区/地籍子区';break;
}
key == 'distance'?this.$message.warning("请输入"+name):this.$message.warning("请选择"+name);
return;
}
}
var layer = null,type = "",dm = "";
if(this.bufferParams.selectDjzq){
layer = this.getLayerByName("DJZQ");
type = 'djzq';
dm = this.bufferParams.selectDjzq;
}else if(this.bufferParams.selectDjq){
layer = this.getLayerByName("DJQ");
type = 'djq';
dm = this.bufferParams.selectDjq;
}
this.queryDjqByDm(this.url+"/"+layer.id,type,dm,function (features) {
if(features.length > 0){
self.createBuffer(features[0].geometry,self.bufferParams.distance,self.viewId,function (bufGeo) {
self.identify(self.url,self.bufferParams.layerId,bufGeo,function(res){
var resultes = res.results;
if(resultes && resultes.length > 0){
self.$parent.delIdentifyData(resultes);
self.$parent.dialogVisible = true;
}else{
self.$message.success("暂无数据!!!");
}
},true,'all',3,view.extent);
})
}
});
},
importIdentity(){
var self = this;
var view = maps[this.viewId];
if(!this.importGeo){
this.$message.warning("请导入空间范围!!");
return;
}
for(var key in this.bufferParams){
if((key == 'distance' || key == 'layerId')&&!this.bufferParams[key].toString()){
var name = "";
switch (key) {
case 'distance':name = '缓冲距离';break;
case 'layerId':name = '分析图层';break;
}
key == 'distance'?this.$message.warning("请输入"+name):this.$message.warning("请选择"+name);
return;
}
}
self.createBuffer(this.importGeo,self.bufferParams.distance,self.viewId,function (bufGeo) {
self.identify(self.url,self.bufferParams.layerId,bufGeo,function(res){
var resultes = res.results;
if(resultes && resultes.length > 0){
self.$parent.delIdentifyData(resultes);
self.$parent.dialogVisible = true;
}else{
self.$message.success("暂无数据!!!");
}
},true,'all',3,view.extent);
})
},
//清除缓冲区参数
resetBufferParams(){
//清除参数
for(var key in this.bufferParams){
if(key == 'distance'){
this.bufferParams[key] = 0;
}else if(key == 'layerId'){
this.bufferParams[key] = []
} else {
this.bufferParams[key] = "";
}
}
//清除结果图层和绘制图层
this.$parent.closeResultDialog();
this.clearBufferLayer();
},
//获取地籍区/地籍子区数据
getDjqList(){
var self = this;
var djqLayer = this.getLayerByName("DJQ");
this.queryAttributes(this.url+"/"+djqLayer.id,"",function (features) {
//self.djqAndDjzq.concat = features;
if(features != null){
for(var i = 0;i < features.length;i++){
var obj = {
dm:features[i].attributes.DJQDM,
mc:features[i].attributes.DJQMC,
type:"djq"
}
self.djqList.push(obj);
}
}
})
},
//获取地籍子区
getDjzqList(){
var self = this,
djzqLayer= this.getLayerByName("DJZQ");
self.djzqList = [];
this.queryAttributes(this.url+"/"+djzqLayer.id,{"DJZQDM":this.bufferParams.selectDjq},function (features) {
if(features != null){
for(var i = 0;i < features.length;i++){
var obj = {
dm:features[i].attributes.DJZQDM,
mc:features[i].attributes.DJZQMC,
type:"djzq"
}
self.djzqList.push(obj);
}
}
})
},
tabClick(name){
if(this.activeName == 'xzfw'){
if(this.djqList.length == 0){
this.djzqList = [];
this.getDjqList();
}
}
},
//设置导入的空间数据
setGeometry(geo){
this.importGeo = geo;
this.importDialog = false;
},
//打开导入空间
openImportDialog(){
this.importDialog = true;
},
}
}
</script>
<style lang="less" scoped>
.tools{
position: relative;
display: flex;
justify-content: space-around;
line-height: 48px;
background-color: #FFFFFF;
box-shadow: 0px 1px 1px 1px rgba(0, 0, 0, 0.18);
border-radius: 4px;
ul{
height: 48px;
li{
margin-top:12px;
padding:0 10px;
border-right: 1px dashed #CBCBCB;
float: left;
height: 24px;
line-height: 24px;
i{
font-size:16px;
color: #8C8E91;
position: relative;
top: 2px;
}
span{
font-size: 12px;
color: #6D7278;
}
}
li:last-child{
border: 0;
}
li :hover{
cursor:pointer
}
}
}
.bufferDialog{
background: #f9f8f7;
margin-top: 5px;
padding-bottom: 20px;
/deep/ .el-tabs__header{
margin: 0px;
}
.contentItem{
margin: 8px 5px;
.drawTypes{
display: contents;
}
}
.buttonDiv{
text-align: center;
}
}
</style>