forked from MapComplete/MapComplete
Move to popups again
This commit is contained in:
parent
3e6def36b8
commit
de9da2c220
11 changed files with 55 additions and 21 deletions
|
@ -5,6 +5,7 @@ import {ElementStorage} from "./ElementStorage";
|
|||
import {Changes} from "./Changes";
|
||||
import L from "leaflet"
|
||||
import {GeoOperations} from "./GeoOperations";
|
||||
import {UIElement} from "../UI/UIElement";
|
||||
|
||||
/***
|
||||
* A filtered layer is a layer which offers a 'set-data' function
|
||||
|
@ -38,6 +39,7 @@ export class FilteredLayer {
|
|||
*/
|
||||
private _geolayer;
|
||||
private _selectedElement: UIEventSource<any>;
|
||||
private _showOnPopup: UIEventSource<(() => UIElement)>;
|
||||
|
||||
constructor(
|
||||
name: string,
|
||||
|
@ -46,8 +48,11 @@ export class FilteredLayer {
|
|||
filters: TagsFilter,
|
||||
maxAllowedOverlap: number,
|
||||
style: ((properties) => any),
|
||||
selectedElement: UIEventSource<any>) {
|
||||
selectedElement: UIEventSource<any>,
|
||||
showOnPopup: UIEventSource<(() => UIElement)>
|
||||
) {
|
||||
this._selectedElement = selectedElement;
|
||||
this._showOnPopup = showOnPopup;
|
||||
|
||||
if (style === undefined) {
|
||||
style = function () {
|
||||
|
@ -177,16 +182,21 @@ export class FilteredLayer {
|
|||
},
|
||||
|
||||
onEachFeature: function (feature, layer) {
|
||||
|
||||
|
||||
let eventSource = self._storage.addOrGetElement(feature);
|
||||
eventSource.addCallback(function () {
|
||||
self.updateStyle();
|
||||
});
|
||||
layer.on("click", function(e){
|
||||
console.log("Selected ",feature)
|
||||
|
||||
|
||||
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();
|
||||
layer.bindPopup(uiElement.Render()).openPopup();
|
||||
uiElement.Update();
|
||||
uiElement.Activate();
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -28,9 +28,14 @@ export class StrayClickHandler {
|
|||
if (self._lastMarker !== undefined) {
|
||||
map.removeLayer(self._lastMarker);
|
||||
}
|
||||
|
||||
self._lastMarker = L.marker([lastClick.lat, lastClick.lon]);
|
||||
const uiElement = uiToShow();
|
||||
const popup = L.popup().setContent(uiElement.Render());
|
||||
uiElement.Activate();
|
||||
uiElement.Update();
|
||||
self._lastMarker.addTo(map);
|
||||
self._lastMarker.bindPopup(popup).openPopup();
|
||||
|
||||
|
||||
leftMessage.setData(self._uiToShow);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue