From ff7250f081c95f97844ec2a71732c39c1459b459 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Wed, 19 May 2021 03:26:57 +0100 Subject: [PATCH] Fix hidden layers duplicating occasionally --- src/leaflet/layer/LayerManager.ts | 4 ++++ src/store/mutations.ts | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/leaflet/layer/LayerManager.ts b/src/leaflet/layer/LayerManager.ts index c88debe..670d6f6 100644 --- a/src/leaflet/layer/LayerManager.ts +++ b/src/leaflet/layer/LayerManager.ts @@ -61,6 +61,10 @@ export default class LayerManager { } addHiddenLayer(layer: Layer, name: string, position: number) { + if(this.layerControl.hasLayer(layer)) { + this.layerControl.removeLayer(layer); + } + if(typeof position !== 'undefined') { this.layerControl.addOverlayAtPosition(layer, name, position); } else { diff --git a/src/store/mutations.ts b/src/store/mutations.ts index 610b5c8..cf41846 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -155,10 +155,11 @@ export const mutations: MutationTree & Mutations = { //Sets the existing marker sets from the last marker fetch [MutationTypes.SET_MARKER_SETS](state: State, markerSets: Map) { - state.markerSets = markerSets; + state.markerSets.clear(); state.pendingSetUpdates.clear(); for(const entry of markerSets) { + state.markerSets.set(entry[0], entry[1]); state.pendingSetUpdates.set(entry[0], { markerUpdates: [], areaUpdates: [],