map.vue
12.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
<template>
<div class="testMap">
<div class="mapTools">
<mapTools :viewId="viewId"></mapTools>
</div>
<EsriMap :viewId = "viewId" :afterLoaderFunction="addLayer"></EsriMap>
<div class="searchDiv">
<el-input placeholder="请输入标识码" clearable v-model="inputBsm"> <el-button slot="append" type="primary" icon="el-icon-search" @click="doSearch"></el-button> </el-input>
<!--搜索弹出框-->
<div class="searchResult" v-show="dialogVisible">
<div class="-header">
<span class="title">地块信息</span>
<span class="closeButton">
<i class="close el-icon-close" @click="closeResultDialog"></i>
</span>
</div>
<el-card class="box-card">
<div slot="header" class="clearfix">
<!-- 图层选择-->
<span class="formTitle">图层选择:</span>
<el-select v-model="selectResLayerId" size="mini" @change="selectLayerChange" placeholder="请选择">
<el-option
v-for="(item,index) in resultLayers"
:key="index"
:label="item.label"
:value="item.id"
>
</el-option>
</el-select>
</div>
<!-- 数据结果-->
<div class="text item" v-for="(item,index) in features" :key="index">
<P>
<span class="title"><i class="iconfont iconxinxi"></i> 基本信息</span>
<a href="#" @click="toMap(item)">缩放至</a>
</P>
<hr />
<div class="contentItem" v-for="(value,key,index) in item.attributes" :key="index">
<span class="key">{{key}}:</span>
<span class="value" :title="value">{{value}}</span>
</div>
</div>
</el-card>
</div>
</div>
</div>
</template>
<script>
import EsriMap from '@/components/map/EsriMap'
import MapTools from './mapWeight/mapTools'
import {loadModules} from 'esri-loader'
import {maps} from '@/libs/map/mapUtils'
import mapLayerManager from "./mapWeight/js/mapLayerManager";
import layers from '@/assets/json/layers.json'
import findTask from '@/libs/map/findTask'
export default {
inject:['getRightTree','getRightTreeByZrzbsm'],
components:{
EsriMap,
MapTools
},
data(){
return{
viewId:"testMap",
layerUrl:"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",
dialogVisible:false,
selectResLayerId:null,
features:[],
resultLayers:[],
results:[],
inputBsm:"",
heighGraphic:null
}
},
mixins:[mapLayerManager,findTask],
mounted(){
var query = this.$route.query
var self = this;
setTimeout(function () {
if(query && JSON.stringify(query) != "{}"){
//self.addGeoByBsm(query.bsm,query.type,self.viewId);
if(query.type == 'zd'){
self.getRightTree(query.bsm)
}else if(query.type == 'zrz'){
self.getRightTreeByZrzbsm(query.bsm);
}
}
},500);
},
methods:{
addLayer(){
var self = this;
var view = maps[this.viewId];
view.ui.remove('zoom');
loadModules([
"esri/layers/MapImageLayer",
"esri/geometry/Extent"
]).then(([
MapImageLayer,
Extent
])=>{
var mapImageLayer = new MapImageLayer({
url:self.layerUrl,
id:"testLayer",
spatialReference:view.spatialReference,
sublayers:[{
id:19,
visible:true
},
{
id:8,
visible:true
},
{
id:10,
visible:true
}]
});
view.map.add(mapImageLayer,1);
mapImageLayer.when(function () {
var extent = new Extent(JSON.parse(JSON.stringify(mapImageLayer.fullExtent)))
extent.spatialReference = view.spatialReference;
view.center = extent.center;
view.zoom = 15;
// view.extent = mapImageLayer.fullExtent;
});
var query = self.$route.query;
if(query && JSON.stringify(query) != "{}"){
self.addGeoByBsm(query.bsm,query.type,self.viewId);
}
}).catch(err => {
throw(err);
})
},
//缩放至
toMap(attr){
var self = this;
if(attr.geometry){
this.extentToGraphic(attr,this.heighGraphic,this.viewId,function () {
self.heighGraphic = attr;
});
}else {
this.$message.warning("没有图形信息!!")
}
},
//图层选择事件
selectLayerChange(){
debugger
var self = this;
this.features = [];
var layerAndResult = this.results.filter(function (item) {
return item.layerId == self.selectResLayerId;
})
if(layerAndResult){
this.features = layerAndResult[0].features;
}
},
//属性查询
doSearch(){
var self = this;
if(!this.inputBsm){
this.$message.warning(" 请输入标识码!!!");
return;
}else if(this.inputBsm.length != 32){
this.$message.warning("标识码格式输入有误!!!");
return;
}
this.findByPro(this.layerUrl,[8,10],'BSM',this.inputBsm,true,function (res) {
var resultes = res.results;
if(resultes && resultes.length > 0){
self.delIdentifyData(resultes);
if(!self.dialogVisible){
self.dialogVisible = true;
}
}else {
self.$message.warning("查询不到相关数据!!!");
}
});
},
//关闭查询结果
closeResultDialog(){
//关闭时清除查询结果 清除数据
this.results = [];
this.selectResLayerId =null;
this.features = [];
this.resultLayers = [];
this.heighGraphic = null;
//清除查询图层
this.clearSearchLayer(this.viewId);
this.dialogVisible = false;
},
//处理数据
delIdentifyData(data){
var self = this;
self.results = [];
self.selectResLayerId =null;
self.features = [];
self.resultLayers = [];
this.heighGraphic = null;
for(var i = 0;i < data.length;i++){
var layerId = data[i].layerId;
var layer = self.getLayerById(layerId);
var layerResult = self.results.filter(function (item) {
return item.layerId == layerId;
})
if(layerResult && layerResult.length > 0){
var feature = data[i].feature,
attributes = {},
fieldAliases = layer.fieldAliases;
for(var key in feature.attributes){
if(!feature.attributes[key]){
delete feature.attributes[key]
}
}
layerResult[0].features.push(feature);
}else{
if(layer){
this.resultLayers.push({
id:layerId,
label:layer.layerLabel
})
var layerAndResult = {
layerId:layerId,
features:[]
}
var feature = data[i].feature,
attributes = {},
fieldAliases = layer.fieldAliases;
for(var key in feature.attributes){
if(!feature.attributes[key]){
delete feature.attributes[key]
}
}
layerAndResult.features.push(feature);
self.results.push(layerAndResult);
}
}
}
this.addSearchResultToMap(this.results,this.viewId);
},
getLayerById(layerId){
var parseLayers = JSON.parse(JSON.stringify(layers));
var layer = parseLayers.filter(function (item) {
return item.id == layerId;
})
if(layer){
return layer[0];
}
return null;
},
//展示查询数据结果
}
}
</script>
<style scoped lang="less">
.testMap{
height: 100%;
width: 100%;
position: relative;
.mapTools{
position: absolute;
top: 12px;
z-index: 99;
right: 5px;
}
.searchDiv{
position: absolute;
top: 12px;
left: 7px;
width: 30%;
max-height: 100%;
/deep/ .el-input-group__append{
background-color: #409eff;
color: white;
}
.searchResult{
margin-top: 3px;
background: white;
border-radius: 4px;
max-height: 80%;
.-header{
line-height: 32px;
padding: 3px 20px;
background-color: #519eff;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
.title{
font-size: 14px;
color: white;
font-weight: 600;
}
.closeButton{
float: right;
font-size: 16px;
color: black;
}
.closeButton :hover{
cursor:pointer
}
}
/deep/ .el-card__header {
padding: 10px 20px;
}
.formTitle{
margin-right: 5px;
font-size: 14px;
}
.item{
p{
margin: 0px 3px;
font-size: 14px;
.title{
}
a{
float: right;
color: #519eff
}
}
.contentItem{
display: flex;
font-size: 14px;
width: 100%;
line-height: 23px;
align-items: center;
.key{
width: 30%;
margin: 5px 3px;
text-align: right;
}
.value{
width: 70%;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
word-break:keep-all;
}
}
}
/deep/ .el-card__body{
max-height: 363px;
overflow: auto;
}
}
}
}
</style>