EsriMap.vue
2.02 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
<template>
<div class="map">
<div :id="viewId" class="viewDiv">
</div>
</div>
</template>
<script>
import {loadModules} from 'esri-loader'
import {maps} from '@/libs/map/mapUtils'
export default {
props:{
viewId:{
type:String,
default:"mainView"
},
afterLoaderFunction:{
type:Function,
default:null
}
},
data(){
return{
}
},
mounted(){
this.initMap();
},
methods:{
initMap(){
var self = this;
loadModules([
"esri/views/MapView",
"esri/Map"
]).then(([
MapView,
esriMap
]) => {
var map = new esriMap({
basemap:"osm"
});
//108.95 34.27
var view = new MapView({
container: self.viewId,
map: map,
zoom:10,
center: [-0.154133333770497,0.6138183594020817],
spatialReference: {
wkid: 102100
}
});
maps[self.viewId] = view;
if(self.afterLoaderFunction && typeof self.afterLoaderFunction == 'function'){
self.afterLoaderFunction(view);
}
}).catch(err => {
throw(err);
});
}
}
}
</script>
<style scoped lang="less">
.map{
height: 100%;
width: 100%;
.viewDiv{
height: 100%;
width: 100%;
}
}
</style>