Fix #26
This commit is contained in:
parent
c87c014045
commit
b2704d0ab8
3 changed files with 25 additions and 18 deletions
|
@ -31,7 +31,7 @@ export class LayerDefinition {
|
||||||
|
|
||||||
|
|
||||||
asLayer(basemap: Basemap, allElements: ElementStorage, changes: Changes, userDetails: UIEventSource<UserDetails>, selectedElement: UIEventSource<any>,
|
asLayer(basemap: Basemap, allElements: ElementStorage, changes: Changes, userDetails: UIEventSource<UserDetails>, selectedElement: UIEventSource<any>,
|
||||||
showOnPopup:UIEventSource<(() => UIElement)>):
|
showOnPopup: (tags: UIEventSource<(any)>) => UIElement):
|
||||||
FilteredLayer {
|
FilteredLayer {
|
||||||
return new FilteredLayer(
|
return new FilteredLayer(
|
||||||
this.name,
|
this.name,
|
||||||
|
|
|
@ -39,7 +39,7 @@ export class FilteredLayer {
|
||||||
*/
|
*/
|
||||||
private _geolayer;
|
private _geolayer;
|
||||||
private _selectedElement: UIEventSource<any>;
|
private _selectedElement: UIEventSource<any>;
|
||||||
private _showOnPopup: UIEventSource<(() => UIElement)>;
|
private _showOnPopup: (tags: UIEventSource<any>) => UIElement;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -49,7 +49,7 @@ export class FilteredLayer {
|
||||||
maxAllowedOverlap: number,
|
maxAllowedOverlap: number,
|
||||||
style: ((properties) => any),
|
style: ((properties) => any),
|
||||||
selectedElement: UIEventSource<any>,
|
selectedElement: UIEventSource<any>,
|
||||||
showOnPopup: UIEventSource<(() => UIElement)>
|
showOnPopup: ((tags: UIEventSource<any>) => UIElement)
|
||||||
) {
|
) {
|
||||||
this._selectedElement = selectedElement;
|
this._selectedElement = selectedElement;
|
||||||
this._showOnPopup = showOnPopup;
|
this._showOnPopup = showOnPopup;
|
||||||
|
@ -177,7 +177,6 @@ export class FilteredLayer {
|
||||||
icon: style.icon
|
icon: style.icon
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return marker;
|
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)
|
console.log("Selected ", feature)
|
||||||
self._selectedElement.setData(feature.properties);
|
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.Update();
|
||||||
uiElement.Activate();
|
uiElement.Activate();
|
||||||
|
|
||||||
|
L.DomEvent.stop(e); // Marks the event as consumed
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
18
index.ts
18
index.ts
|
@ -26,10 +26,10 @@ let dryRun = false;
|
||||||
if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
|
if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
|
||||||
|
|
||||||
// Set to true if testing and changes should NOT be saved
|
// Set to true if testing and changes should NOT be saved
|
||||||
// dryRun = true;
|
// dryRun = true;
|
||||||
// If you have a testfile somewhere, enable this to spoof overpass
|
// 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
|
// 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) {
|
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 = {
|
const addButton = {
|
||||||
name: layer.name,
|
name: layer.name,
|
||||||
|
|
Loading…
Reference in a new issue