-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathBgLayerList.vue
More file actions
94 lines (92 loc) · 2.69 KB
/
BgLayerList.vue
File metadata and controls
94 lines (92 loc) · 2.69 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
<template>
<v-sheet elevation="8">
<v-slide-group ref="slideGroup"
mandatory
show-arrows
class="pa-1"
selected-class="bg-secondary"
@update:modelValue="onSelectLayer"
:model-value="selectedLid"
>
<v-slide-group-item
v-for="layer in displayedLayers"
:key="layer.get('lid')"
:value="layer.get('lid')"
v-slot:default="{ toggle, selectedClass }"
>
<v-card
hover
:width="imageWidth"
:class="['ma-1', selectedClass]"
@click="toggle"
@keyup.enter="toggle"
>
<wgu-layerpreviewimage
:layer="layer"
:mapView="map.getView()"
:width="imageWidth"
:height="imageHeight"
:previewIcon="previewIcon"
/>
<v-card-title class="pt-3">
<span class="d-inline-block text-truncate text-caption font-weight-regular">
{{ layer.get('name') }}
</span>
</v-card-title>
</v-card>
</v-slide-group-item>
</v-slide-group>
</v-sheet>
</template>
<script>
import { useMap } from '@/composables/Map';
import LayerPreviewImage from './LayerPreviewImage.vue';
export default {
name: 'wgu-bglayerlist',
components: {
'wgu-layerpreviewimage': LayerPreviewImage
},
props: {
imageWidth: { type: Number, required: true },
imageHeight: { type: Number, required: true },
previewIcon: { type: String, required: true }
},
setup () {
const { map, layers } = useMap();
return { map, layers };
},
methods: {
/**
* Handler for click on item in layer list:
* Set the selected background layer to visible and hide all other background layers.
* @param {Object} selLid ID of layer selected by the user
*/
onSelectLayer (selLid) {
const selLayer = this.displayedLayers.find(layer => layer.get('lid') === selLid);
selLayer.setVisible(true);
this.displayedLayers
.filter(layer => layer !== selLayer)
.forEach(layer => {
layer.setVisible(false);
});
}
},
computed: {
/**
* Reactive property to return the OpenLayers layers marked as 'isBaseLayer'.
*/
displayedLayers () {
return this.layers
.filter(layer => layer.get('isBaseLayer'));
},
/**
* Reactive property to return the currently visible OpenLayers background layer ID.
* To disambiguate multiple selected background layers - which may occur programmatically -
* this returns the first in the list of background layers.
*/
selectedLid () {
return this.displayedLayers.find(layer => layer.getVisible())?.get('lid');
}
}
};
</script>