forked from MapComplete/MapComplete
Refactoring of GPS-location (uses featureSource too now), factoring out state, add ReplaceGeometryAction and conflation example
This commit is contained in:
parent
1db54f3c8e
commit
2484848cd6
37 changed files with 1035 additions and 467 deletions
28
UI/Base/AsyncLazy.ts
Normal file
28
UI/Base/AsyncLazy.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import BaseUIElement from "../BaseUIElement";
|
||||
import {VariableUiElement} from "./VariableUIElement";
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import Loading from "./Loading";
|
||||
|
||||
export default class AsyncLazy extends BaseUIElement{
|
||||
private readonly _f: () => Promise<BaseUIElement>;
|
||||
|
||||
constructor(f: () => Promise<BaseUIElement>) {
|
||||
super();
|
||||
this._f = f;
|
||||
}
|
||||
|
||||
protected InnerConstructElement(): HTMLElement {
|
||||
// The caching of the BaseUIElement will guarantee that _f will only be called once
|
||||
|
||||
return new VariableUiElement(
|
||||
UIEventSource.FromPromise(this._f()).map(el => {
|
||||
if(el === undefined){
|
||||
return new Loading()
|
||||
}
|
||||
return el
|
||||
})
|
||||
|
||||
).ConstructElement()
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@ export interface MinimapOptions {
|
|||
export interface MinimapObj {
|
||||
readonly leafletMap: UIEventSource<any>,
|
||||
installBounds(factor: number | BBox, showRange?: boolean) : void
|
||||
TakeScreenshot(): Promise<any>;
|
||||
}
|
||||
|
||||
export default class Minimap {
|
||||
|
|
|
@ -9,6 +9,7 @@ import {Map} from "leaflet";
|
|||
import Minimap, {MinimapObj, MinimapOptions} from "./Minimap";
|
||||
import {BBox} from "../../Logic/BBox";
|
||||
import 'leaflet-polylineoffset'
|
||||
import {SimpleMapScreenshoter} from "leaflet-simple-map-screenshoter";
|
||||
|
||||
export default class MinimapImplementation extends BaseUIElement implements MinimapObj {
|
||||
private static _nextId = 0;
|
||||
|
@ -278,4 +279,10 @@ export default class MinimapImplementation extends BaseUIElement implements Mini
|
|||
|
||||
this.leafletMap.setData(map)
|
||||
}
|
||||
|
||||
public async TakeScreenshot(){
|
||||
const screenshotter = new SimpleMapScreenshoter();
|
||||
screenshotter.addTo(this.leafletMap.data);
|
||||
return await screenshotter.takeScreen('image')
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue