This commit is contained in:
Pieter Vander Vennet 2020-07-01 16:32:17 +02:00
parent c87c014045
commit b2704d0ab8
3 changed files with 25 additions and 18 deletions

View file

@ -39,7 +39,7 @@ export class FilteredLayer {
*/
private _geolayer;
private _selectedElement: UIEventSource<any>;
private _showOnPopup: UIEventSource<(() => UIElement)>;
private _showOnPopup: (tags: UIEventSource<any>) => UIElement;
constructor(
name: string,
@ -49,7 +49,7 @@ export class FilteredLayer {
maxAllowedOverlap: number,
style: ((properties) => any),
selectedElement: UIEventSource<any>,
showOnPopup: UIEventSource<(() => UIElement)>
showOnPopup: ((tags: UIEventSource<any>) => UIElement)
) {
this._selectedElement = selectedElement;
this._showOnPopup = showOnPopup;
@ -177,7 +177,6 @@ export class FilteredLayer {
icon: style.icon
});
}
return marker;
},
@ -188,21 +187,17 @@ export class FilteredLayer {
});
layer.on("click", function(e) {
const uiElement = self._showOnPopup(eventSource);
layer.bindPopup(uiElement.Render());
layer.on("click", function (e) {
console.log("Selected ", feature)
self._selectedElement.setData(feature.properties);
L.DomEvent.stop(e); // Marks the event as consumed
const uiElement = self._showOnPopup.data();
const popup = L.popup();
popup.setContent(uiElement.Render());
layer.bindPopup(popup).openPopup();
popup.onclose(() => {
layer.removePopup(popup)
});
uiElement.Update();
uiElement.Activate();
L.DomEvent.stop(e); // Marks the event as consumed
});
}
});