File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 4
4
<wgu-layerlistitem
5
5
v-for =" layer in displayedLayers"
6
6
:key =" layer.get('lid')"
7
- :layer =" layer"
7
+ :layer =" layer.getLayer() "
8
8
:mapView =" map.getView()"
9
9
:showLegends =" showLegends"
10
10
:showOpacityControls =" showOpacityControls"
13
13
</template >
14
14
15
15
<script >
16
+ import { LayerCollectionProxy } from ' @/util/Layer' ;
16
17
import { Mapable } from ' ../../mixins/Mapable' ;
17
18
import LayerListItem from ' ./LayerListItem'
18
19
@@ -28,7 +29,7 @@ export default {
28
29
},
29
30
data () {
30
31
return {
31
- layers : []
32
+ layersProxy : undefined
32
33
}
33
34
},
34
35
methods: {
@@ -37,16 +38,23 @@ export default {
37
38
* Bind to the layers from the OpenLayers map.
38
39
*/
39
40
onMapBound () {
40
- this .layers = this .map .getLayers ().getArray ();
41
+ this .layersProxy = new LayerCollectionProxy (this .map .getLayers (),
42
+ [' lid' , ' displayInLayerList' , ' isBaseLayer' ]);
41
43
}
42
44
},
45
+ destroyed () {
46
+ this .layersProxy .destroy ();
47
+ },
43
48
computed: {
44
49
/**
45
50
* Reactive property to return the OpenLayers layers to be shown in the control.
46
51
* Remarks: The 'displayInLayerList' attribute should default to true per convention.
47
52
*/
48
53
displayedLayers () {
49
- return this .layers
54
+ if (! this .layersProxy ) {
55
+ return [];
56
+ }
57
+ return this .layersProxy .getArray ()
50
58
.filter (layer => layer .get (' displayInLayerList' ) !== false && ! layer .get (' isBaseLayer' ))
51
59
.reverse ();
52
60
}
You can’t perform that action at this time.
0 commit comments