mapLayerManager.js
2.64 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
import layers from '@/assets/json/layers.json'
import graphicSymbol from '@/assets/json/graphicSymbol.json'
import queryUtils from "@libs/map/queryUtils";
import {loadModules} from "esri-loader"
import {maps} from '@/libs/map/mapUtils'
export default {
methods:{
getLayerByName(name) {
for (var i = 0; i < layers.length; i++) {
if (layers[i].layerName == name) {
return layers[i];
}
}
return null;
},
addGeoByBsm(bsm, type,viewId) {
var self = this;
var layer = null;
if (type == 'zd') {
layer = this.getLayerByName("ZDJBXX");
} else if (type == 'zrz') {
layer = this.getLayerByName("ZRZ");
} else {
console.log("未定义类型!!");
return;
}
if (!layer) {
console.log("没有找到图层,不能查询");
return;
}
queryUtils.methods.queryByWhere(layer.layerUrl+"/"+layer.id, {"BSM": bsm }, null, true, null, null, function (res) {
var features = res.features;
if(features && features.length > 0){
if( !features[0].geometry ){
self.$message.success("暂无图形信息!!");
return;
}
loadModules([
"esri/layers/GraphicsLayer"
]).then( ([
GraphicsLayer
]) => {
var view = maps[viewId];
var layer = view.map.findLayerById("highlightLayer");
if(layer){
layer.removeAll();
}else {
layer = new GraphicsLayer({
id:"highlightLayer"
})
view.map.add(layer);
}
var symbol = graphicSymbol.fillSymbol.highlightSymbol;
var graphic = features[0];
graphic.symbol = symbol;
layer.add(graphic);
view.center = graphic.geometry.extent.center;
}).catch( err => {
thow(err);
})
}else {
self.$message.success("暂无图形信息!!");
return;
}
});
},
}
}