File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 <wgu-layerlistitem
55 v-for =" layer in displayedLayers"
66 :key =" layer.get('lid')"
7- :layer =" layer"
7+ :layer =" layer.getLayer() "
88 :mapView =" map.getView()"
99 :showLegends =" showLegends"
1010 :showOpacityControls =" showOpacityControls"
1313</template >
1414
1515<script >
16+ import { LayerCollectionProxy } from ' @/util/Layer' ;
1617import { Mapable } from ' ../../mixins/Mapable' ;
1718import LayerListItem from ' ./LayerListItem'
1819
@@ -28,7 +29,7 @@ export default {
2829 },
2930 data () {
3031 return {
31- layers : []
32+ layersProxy : undefined
3233 }
3334 },
3435 methods: {
@@ -37,16 +38,23 @@ export default {
3738 * Bind to the layers from the OpenLayers map.
3839 */
3940 onMapBound () {
40- this .layers = this .map .getLayers ().getArray ();
41+ this .layersProxy = new LayerCollectionProxy (this .map .getLayers (),
42+ [' lid' , ' displayInLayerList' , ' isBaseLayer' ]);
4143 }
4244 },
45+ destroyed () {
46+ this .layersProxy .destroy ();
47+ },
4348 computed: {
4449 /**
4550 * Reactive property to return the OpenLayers layers to be shown in the control.
4651 * Remarks: The 'displayInLayerList' attribute should default to true per convention.
4752 */
4853 displayedLayers () {
49- return this .layers
54+ if (! this .layersProxy ) {
55+ return [];
56+ }
57+ return this .layersProxy .getArray ()
5058 .filter (layer => layer .get (' displayInLayerList' ) !== false && ! layer .get (' isBaseLayer' ))
5159 .reverse ();
5260 }
You can’t perform that action at this time.
0 commit comments