map.vue
2.2 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
<template>
<div class="testMap">
<div class="mapTools">
<mapTools :viewId="viewId"></mapTools>
</div>
<EsriMap :viewId = "viewId" :afterLoaderFunction="addLayer"></EsriMap>
</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";
export default {
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"
}
},
mixins:[mapLayerManager],
mounted(){
var query = this.$route.query;
if(query && JSON.stringify(query) != "{}"){
this.addGeoByBsm(query.bsm,query.type,this.viewId);
}
},
methods:{
addLayer(){
var self = this;
var view = maps[this.viewId];
loadModules([
"esri/layers/MapImageLayer",
]).then(([
MapImageLayer,
])=>{
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);
}).catch(err => {
throw(err);
})
}
}
}
</script>
<style scoped lang="less">
.testMap{
height: 100%;
width: 100%;
position: relative;
.mapTools{
position: absolute;
top: 12px;
z-index: 99;
right: 5px;
}
}
</style>