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

@ -31,7 +31,7 @@ export class LayerDefinition {
asLayer(basemap: Basemap, allElements: ElementStorage, changes: Changes, userDetails: UIEventSource<UserDetails>, selectedElement: UIEventSource<any>,
showOnPopup:UIEventSource<(() => UIElement)>):
showOnPopup: (tags: UIEventSource<(any)>) => UIElement):
FilteredLayer {
return new FilteredLayer(
this.name,

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
});
}
});

View file

@ -29,7 +29,7 @@ if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
// dryRun = true;
// If you have a testfile somewhere, enable this to spoof overpass
// This should be hosted independantly, e.g. with `cd assets; webfsd -p 8080` + a CORS plugin to disable cors rules
// Overpass.testUrl = "http://127.0.0.1:8080/test.json";
Overpass.testUrl = null; // "http://127.0.0.1:8080/test.json";
}
@ -115,7 +115,19 @@ const flayers: FilteredLayer[] = []
for (const layer of questSetToRender.layers) {
const flayer = layer.asLayer(bm, allElements, changes, osmConnection.userDetails, selectedElement, leftMessage);
const generateInfo = (tagsES) => {
return new FeatureInfoBox(
tagsES,
layer.elementsToShow,
layer.questions,
changes,
osmConnection.userDetails
)
};
const flayer = layer.asLayer(bm, allElements, changes, osmConnection.userDetails, selectedElement,
generateInfo);
const addButton = {
name: layer.name,