1010 <v-checkbox
1111 color =" secondary"
1212 hide-details
13- :input-value =" layer .getVisible()"
13+ :input-value =" layerProxy .getVisible()"
1414 @click.capture.stop =" onItemClick()"
1515 />
1616 </v-list-item-action >
1717 <v-list-item-title >
18- {{ layer .get('name') }}
18+ {{ layerProxy .get('name') }}
1919 </v-list-item-title >
2020 </template >
2121 <v-list-item
2222 v-if =" showOpacityControl"
2323 class =" overflow-visible"
2424 >
2525 <wgu-layeropacitycontrol
26- :layer =" layer "
26+ :layer =" layerProxy.getLayer() "
2727 />
2828 </v-list-item >
2929 <v-list-item
3434 requests when the layer item is not expanded.
3535 -->
3636 <wgu-layerlegendimage v-if =" open"
37- :layer =" layer "
37+ :layer =" layerProxy.getLayer() "
3838 :mapView =" mapView"
3939 />
4040 </v-list-item >
4949 <v-checkbox
5050 color =" secondary"
5151 hide-details
52- :input-value =" layer .getVisible()"
53- @click.capture.stop =" onItemClick(layer )"
52+ :input-value =" layerProxy .getVisible()"
53+ @click.capture.stop =" onItemClick(layerProxy )"
5454 />
5555 </v-list-item-action >
5656 <v-list-item-content >
5757 <v-list-item-title >
58- {{ layer .get('name') }}
58+ {{ layerProxy .get('name') }}
5959 </v-list-item-title >
6060 </v-list-item-content >
6161 </v-list-item >
6464<script >
6565import LayerLegendImage from ' ./LayerLegendImage'
6666import LayerOpacityControl from ' ./LayerOpacityControl'
67+ import { LayerProxy } from ' ../../util/Layer'
6768
6869export default {
6970 name: ' wgu-layerlistitem' ,
@@ -73,7 +74,8 @@ export default {
7374 },
7475 data () {
7576 return {
76- open: false
77+ open: false ,
78+ layerProxy: new LayerProxy (this .layer , [' name' , ' legend' , ' opacityControl' ])
7779 }
7880 },
7981 props: {
@@ -82,12 +84,15 @@ export default {
8284 showLegends: { type: Boolean , required: true },
8385 showOpacityControls: { type: Boolean , required: true }
8486 },
87+ destroyed () {
88+ this .layerProxy .destroy ();
89+ },
8590 methods: {
8691 /**
8792 * Handler for click on layer item, toggles the layer`s visibility.
8893 */
8994 onItemClick () {
90- this .layer .setVisible (! this .layer .getVisible ());
95+ this .layerProxy .setVisible (! this .layerProxy .getVisible ());
9196 }
9297 },
9398 computed: {
@@ -101,13 +106,13 @@ export default {
101106 * Returns true, if the layer item should show a legend image.
102107 */
103108 showLegend () {
104- return this .showLegends && !! this .layer .get (' legend' );
109+ return this .showLegends && !! this .layerProxy .get (' legend' );
105110 },
106111 /**
107112 * Returns true, if the layer item should show an opacity control.
108113 */
109114 showOpacityControl () {
110- return this .showOpacityControls && !! this .layer .get (' opacityControl' );
115+ return this .showOpacityControls && !! this .layerProxy .get (' opacityControl' );
111116 }
112117 }
113118};
0 commit comments