From 21280fd156c6c30a0b205b6b997b2cad6b0bae0c Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 27 Jul 2020 00:14:34 +0200 Subject: [PATCH] Performance optimization, icon anchor position --- Logic/FilteredLayer.ts | 13 ++++++------- Logic/LayerUpdater.ts | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Logic/FilteredLayer.ts b/Logic/FilteredLayer.ts index c5c23723f..df8c6cf0a 100644 --- a/Logic/FilteredLayer.ts +++ b/Logic/FilteredLayer.ts @@ -228,13 +228,12 @@ export class FilteredLayer { } let eventSource = self._storage.addOrGetElement(feature); const uiElement = self._showOnPopup(eventSource, feature); - const popup = L.popup().setContent(uiElement.Render()); - uiElement.Update(); - marker.bindPopup(popup); - marker.on("click", () => { - console.log("Popup opened"); - uiElement.Activate(); - }) // TODO FIX + const popup = L.popup({}, marker).setContent(uiElement.Render()); + marker.bindPopup(popup) + .on("popupopen", (popup) => { + uiElement.Activate(); + uiElement.Update(); + }); return marker; }, diff --git a/Logic/LayerUpdater.ts b/Logic/LayerUpdater.ts index 24749f67b..70c10d3cb 100644 --- a/Logic/LayerUpdater.ts +++ b/Logic/LayerUpdater.ts @@ -46,15 +46,27 @@ export class LayerUpdater { } private handleData(geojson: any) { - this.runningQuery.setData(false); + const self = this; + function renderLayers(layers: FilteredLayer[]) { + if (layers.length === 0) { + self.runningQuery.setData(false); - for (const layer of this._layers) { - geojson = layer.SetApplicableData(geojson); + if (geojson.features.length > 0) { + console.log("Got some leftovers: ", geojson) + } + return; + } + window.setTimeout(() => { + + const layer = layers[0]; + const rest = layers.slice(1, layers.length); + geojson = layer.SetApplicableData(geojson); + renderLayers(rest); + }, 50) } - if (geojson.features.length > 0) { - console.log("Got some leftovers: ", geojson) - } + renderLayers(this._layers); + } private _failCount = 0;