Optimazation: the popup content is only initialized when the popup marker is clicked
This commit is contained in:
parent
eab842d18a
commit
8bb9b1228b
1 changed files with 11 additions and 5 deletions
|
@ -186,13 +186,11 @@ export class FilteredLayer {
|
||||||
}
|
}
|
||||||
this._dataFromOverpass = fusedFeatures;
|
this._dataFromOverpass = fusedFeatures;
|
||||||
|
|
||||||
console.log("New elements are ", this._newElements)
|
|
||||||
for (const feature of this._newElements) {
|
for (const feature of this._newElements) {
|
||||||
if (!idsFromOverpass.has(feature.properties.id)) {
|
if (!idsFromOverpass.has(feature.properties.id)) {
|
||||||
// This element is not yet uploaded or not yet visible in overpass
|
// This element is not yet uploaded or not yet visible in overpass
|
||||||
// We include it in the layer
|
// We include it in the layer
|
||||||
fusedFeatures.push(feature);
|
fusedFeatures.push(feature);
|
||||||
console.log("Adding ", feature," to fusedFeatures")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,10 +235,18 @@ export class FilteredLayer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let eventSource = State.state.allElements.addOrGetElement(feature);
|
let eventSource = State.state.allElements.addOrGetElement(feature);
|
||||||
const uiElement = self._showOnPopup(eventSource, feature);
|
const popup = L.popup({}, marker);
|
||||||
const popup = L.popup({}, marker).setContent(uiElement.Render());
|
let uiElement: UIElement;
|
||||||
|
let content = undefined;
|
||||||
marker.bindPopup(popup)
|
marker.bindPopup(popup)
|
||||||
.on("popupopen", () => {
|
.on("popupopen", () => {
|
||||||
|
|
||||||
|
if (content === undefined) {
|
||||||
|
uiElement = self._showOnPopup(eventSource, feature);
|
||||||
|
// Lazily create the content
|
||||||
|
content = uiElement.Render();
|
||||||
|
}
|
||||||
|
popup.setContent(content);
|
||||||
uiElement.Activate();
|
uiElement.Activate();
|
||||||
uiElement.Update();
|
uiElement.Update();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue