10
10
<v-checkbox
11
11
color =" secondary"
12
12
hide-details
13
- :input-value =" layer .getVisible()"
13
+ :input-value =" layerProxy .getVisible()"
14
14
@click.capture.stop =" onItemClick()"
15
15
/>
16
16
</v-list-item-action >
17
17
<v-list-item-title >
18
- {{ layer .get('name') }}
18
+ {{ layerProxy .get('name') }}
19
19
</v-list-item-title >
20
20
</template >
21
21
<v-list-item
22
22
v-if =" showOpacityControl"
23
23
class =" overflow-visible"
24
24
>
25
25
<wgu-layeropacitycontrol
26
- :layer =" layer "
26
+ :layer =" layerProxy.getLayer() "
27
27
/>
28
28
</v-list-item >
29
29
<v-list-item
34
34
requests when the layer item is not expanded.
35
35
-->
36
36
<wgu-layerlegendimage v-if =" open"
37
- :layer =" layer "
37
+ :layer =" layerProxy.getLayer() "
38
38
:mapView =" mapView"
39
39
/>
40
40
</v-list-item >
49
49
<v-checkbox
50
50
color =" secondary"
51
51
hide-details
52
- :input-value =" layer .getVisible()"
53
- @click.capture.stop =" onItemClick(layer )"
52
+ :input-value =" layerProxy .getVisible()"
53
+ @click.capture.stop =" onItemClick(layerProxy )"
54
54
/>
55
55
</v-list-item-action >
56
56
<v-list-item-content >
57
57
<v-list-item-title >
58
- {{ layer .get('name') }}
58
+ {{ layerProxy .get('name') }}
59
59
</v-list-item-title >
60
60
</v-list-item-content >
61
61
</v-list-item >
64
64
<script >
65
65
import LayerLegendImage from ' ./LayerLegendImage'
66
66
import LayerOpacityControl from ' ./LayerOpacityControl'
67
+ import { LayerProxy } from ' ../../util/Layer'
67
68
68
69
export default {
69
70
name: ' wgu-layerlistitem' ,
@@ -73,7 +74,8 @@ export default {
73
74
},
74
75
data () {
75
76
return {
76
- open: false
77
+ open: false ,
78
+ layerProxy: new LayerProxy (this .layer , [' name' , ' legend' , ' opacityControl' ])
77
79
}
78
80
},
79
81
props: {
@@ -82,12 +84,15 @@ export default {
82
84
showLegends: { type: Boolean , required: true },
83
85
showOpacityControls: { type: Boolean , required: true }
84
86
},
87
+ destroyed () {
88
+ this .layerProxy .destroy ();
89
+ },
85
90
methods: {
86
91
/**
87
92
* Handler for click on layer item, toggles the layer`s visibility.
88
93
*/
89
94
onItemClick () {
90
- this .layer .setVisible (! this .layer .getVisible ());
95
+ this .layerProxy .setVisible (! this .layerProxy .getVisible ());
91
96
}
92
97
},
93
98
computed: {
@@ -101,13 +106,13 @@ export default {
101
106
* Returns true, if the layer item should show a legend image.
102
107
*/
103
108
showLegend () {
104
- return this .showLegends && !! this .layer .get (' legend' );
109
+ return this .showLegends && !! this .layerProxy .get (' legend' );
105
110
},
106
111
/**
107
112
* Returns true, if the layer item should show an opacity control.
108
113
*/
109
114
showOpacityControl () {
110
- return this .showOpacityControls && !! this .layer .get (' opacityControl' );
115
+ return this .showOpacityControls && !! this .layerProxy .get (' opacityControl' );
111
116
}
112
117
}
113
118
};
0 commit comments