-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathOverviewMapPanel.vue
More file actions
96 lines (94 loc) · 2.32 KB
/
OverviewMapPanel.vue
File metadata and controls
96 lines (94 loc) · 2.32 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
<template>
<v-sheet :width="width" :height="height"
elevation="8" class="pa-1" ref="overviewmapPanel">
</v-sheet>
</template>
<script>
import { useMap } from '@/composables/Map';
import OverviewMapController from './OverviewMapController';
export default {
name: 'wgu-overviewmap-panel',
props: {
rotateWithView: { type: Boolean, required: true },
width: { type: Number, required: true },
height: { type: Number, required: true }
},
setup () {
const { map, layers } = useMap();
return { map, layers };
},
mounted () {
this.createOverviewMapCtrl();
},
unmounted () {
this.destroyOverviewMapCtrl();
},
methods: {
/**
* This function is executed, after the map is bound.
*/
onMapBound () {
this.createOverviewMapCtrl();
},
/**
* This function is executed, before the map is unbound.
*/
onMapUnbound () {
this.destroyOverviewMapCtrl();
},
/**
* Creates the OpenLayers overview map control.
*/
createOverviewMapCtrl () {
const panel = this.$refs.overviewmapPanel;
if (this.map && panel && !this.overviewMap) {
this.overviewMap = new OverviewMapController(this.map, panel.$el, this.$props);
}
},
/**
* Tears down the OpenLayers overview map control.
*/
destroyOverviewMapCtrl () {
if (this.overviewMap) {
this.overviewMap.destroy();
this.overviewMap = undefined;
}
}
},
computed: {
/**
* Reactive property to return the currently visible OpenLayers background layer.
* To disambiguate multiple selected background layers - which may occur programmatically -
* this returns the first in the list of background layers.
*/
selectedBgLayer () {
return this.layers
.filter(layer => layer.get('isBaseLayer'))
.reverse()
.find(layer => layer.getVisible());
}
},
watch: {
map: {
handler (newMap, oldMap) {
if (newMap) {
this.onMapBound();
} else {
if (oldMap) {
this.onMapUnbound();
}
}
},
immediate: true
},
/**
* Watch for background layer selection change.
*/
selectedBgLayer () {
if (this.overviewMap) {
this.overviewMap.setLayer(this.selectedBgLayer);
}
}
}
};
</script>