From 4393890661a783ce2cb17d91531aab47c962ee7b Mon Sep 17 00:00:00 2001 From: James Lyne Date: Mon, 14 Dec 2020 00:35:56 +0000 Subject: [PATCH] Respect marker set hidden by default config --- src/api.ts | 2 +- src/components/map/layer/MarkerSetLayer.vue | 7 +++---- src/leaflet/layer/LayerManager.ts | 4 ++++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/api.ts b/src/api.ts index c5441a5..fa886b7 100644 --- a/src/api.ts +++ b/src/api.ts @@ -490,7 +490,7 @@ export default { sets.set(key, { id: key, label: set.label || "Unnamed set", - hidden: set.hidden || false, + hidden: set.hide || false, priority: set.layerprio || 0, showLabels: set.showlabels || undefined, minZoom: set.minzoom || undefined, diff --git a/src/components/map/layer/MarkerSetLayer.vue b/src/components/map/layer/MarkerSetLayer.vue index 95fc3d6..814a1d7 100644 --- a/src/components/map/layer/MarkerSetLayer.vue +++ b/src/components/map/layer/MarkerSetLayer.vue @@ -48,10 +48,9 @@ export default defineComponent({ }, mounted() { - // console.log('Mounted markerSetLayer'); - - if(!this.markerSet.hidden) { - // console.log('Adding markerSetLayer'); + if(this.markerSet.hidden) { + this.leaflet.getLayerManager().addHiddenLayer(this.layerGroup, this.markerSet.label, 1); + } else { this.leaflet.getLayerManager().addLayer(this.layerGroup, true, this.markerSet.label, 1); } }, diff --git a/src/leaflet/layer/LayerManager.ts b/src/leaflet/layer/LayerManager.ts index d4c5111..0670ab0 100644 --- a/src/leaflet/layer/LayerManager.ts +++ b/src/leaflet/layer/LayerManager.ts @@ -26,6 +26,10 @@ export default class LayerManager { } } + addHiddenLayer(layer: Layer, name: string, position: number) { + this.layerControl.addOverlay(layer, name); + } + removeLayer(layer: Layer) { this.map.removeLayer(layer); this.layerControl.removeLayer(layer);