forked from MapComplete/MapComplete
Small fixes
This commit is contained in:
commit
55539b7c3a
263 changed files with 13321 additions and 2357 deletions
36
Logic/Actors/ChangeToElementsActor.ts
Normal file
36
Logic/Actors/ChangeToElementsActor.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import {ElementStorage} from "../ElementStorage";
|
||||
import {Changes} from "../Osm/Changes";
|
||||
|
||||
export default class ChangeToElementsActor {
|
||||
constructor(changes: Changes, allElements: ElementStorage) {
|
||||
changes.pendingChanges.addCallbackAndRun(changes => {
|
||||
for (const change of changes) {
|
||||
const id = change.type + "/" + change.id;
|
||||
if (!allElements.has(id)) {
|
||||
continue; // Ignored as the geometryFixer will introduce this
|
||||
}
|
||||
const src = allElements.getEventSourceById(id)
|
||||
|
||||
let changed = false;
|
||||
for (const kv of change.tags ?? []) {
|
||||
// Apply tag changes and ping the consumers
|
||||
const k = kv.k
|
||||
let v = kv.v
|
||||
if (v === "") {
|
||||
v = undefined;
|
||||
}
|
||||
if (src.data[k] === v) {
|
||||
continue
|
||||
}
|
||||
changed = true;
|
||||
src.data[k] = v;
|
||||
}
|
||||
if (changed) {
|
||||
src.ping()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -23,12 +23,16 @@
|
|||
//minimap op index.html -> hidden daar alles op doen en dan weg
|
||||
//minimap - leaflet map ophalen - boundaries ophalen - State.state.featurePipeline
|
||||
screenshotter.addTo(State.state.leafletMap.data);
|
||||
let doc = new jsPDF('l');
|
||||
let doc = new jsPDF('landscape');
|
||||
console.log("Taking screenshot")
|
||||
screenshotter.takeScreen('image').then(image => {
|
||||
if(!(image instanceof Blob)){
|
||||
alert("Exporting failed :(")
|
||||
return;
|
||||
}
|
||||
let file = new PDFLayout();
|
||||
file.AddLayout(layout, doc, image);
|
||||
console.log("SCREENSHOTTER");
|
||||
doc.save(name);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import * as L from "leaflet";
|
||||
import {UIEventSource} from "../UIEventSource";
|
||||
import {Utils} from "../../Utils";
|
||||
import Svg from "../../Svg";
|
||||
import Img from "../../UI/Base/Img";
|
||||
import {LocalStorageSource} from "../Web/LocalStorageSource";
|
||||
import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
|
||||
import {VariableUiElement} from "../../UI/Base/VariableUIElement";
|
||||
import BaseUIElement from "../../UI/BaseUIElement";
|
||||
|
||||
export default class GeoLocationHandler extends VariableUiElement {
|
||||
/**
|
||||
|
@ -44,11 +44,13 @@ export default class GeoLocationHandler extends VariableUiElement {
|
|||
* @private
|
||||
*/
|
||||
private readonly _leafletMap: UIEventSource<L.Map>;
|
||||
|
||||
/**
|
||||
* The date when the user requested the geolocation. If we have a location, it'll autozoom to it the first 30 secs
|
||||
* @private
|
||||
*/
|
||||
private _lastUserRequest: Date;
|
||||
|
||||
/**
|
||||
* A small flag on localstorage. If the user previously granted the geolocation, it will be set.
|
||||
* On firefox, the permissions api is broken (probably fingerprint resistiance) and "granted + don't ask again" doesn't stick between sessions.
|
||||
|
@ -77,19 +79,23 @@ export default class GeoLocationHandler extends VariableUiElement {
|
|||
super(
|
||||
hasLocation.map(
|
||||
(hasLocationData) => {
|
||||
let icon: BaseUIElement;
|
||||
|
||||
if (isLocked.data) {
|
||||
return Svg.crosshair_locked_ui();
|
||||
icon = Svg.location_svg();
|
||||
} else if (hasLocationData) {
|
||||
return Svg.crosshair_blue_ui();
|
||||
icon = Svg.location_empty_svg();
|
||||
} else if (isActive.data) {
|
||||
return Svg.crosshair_blue_center_ui();
|
||||
icon = Svg.location_empty_svg();
|
||||
} else {
|
||||
return Svg.crosshair_ui();
|
||||
icon = Svg.location_circle_svg();
|
||||
}
|
||||
return icon
|
||||
},
|
||||
[isActive, isLocked]
|
||||
)
|
||||
);
|
||||
this.SetClass("mapcontrol")
|
||||
this._isActive = isActive;
|
||||
this._isLocked = isLocked;
|
||||
this._permission = new UIEventSource<string>("");
|
||||
|
|
|
@ -23,4 +23,4 @@
|
|||
doc.addImage(image, 'PNG', 15, 30, 150*screenRatio, 150);
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ export default class PendingChangesUploader {
|
|||
constructor(changes: Changes, selectedFeature: UIEventSource<any>) {
|
||||
const self = this;
|
||||
this.lastChange = new Date();
|
||||
changes.pending.addCallback(() => {
|
||||
changes.pendingChanges.addCallback(() => {
|
||||
self.lastChange = new Date();
|
||||
|
||||
window.setTimeout(() => {
|
||||
|
@ -54,7 +54,7 @@ export default class PendingChangesUploader {
|
|||
|
||||
|
||||
function onunload(e) {
|
||||
if (changes.pending.data.length == 0) {
|
||||
if(changes.pendingChanges.data.length == 0){
|
||||
return;
|
||||
}
|
||||
changes.flushChanges("onbeforeunload - probably closing or something similar");
|
||||
|
|
|
@ -13,7 +13,7 @@ export default class SelectedFeatureHandler {
|
|||
private readonly _hash: UIEventSource<string>;
|
||||
private readonly _selectedFeature: UIEventSource<any>;
|
||||
|
||||
private static readonly _no_trigger_on = ["welcome","copyright","layers"]
|
||||
private static readonly _no_trigger_on = ["welcome","copyright","layers","new"]
|
||||
private readonly _osmApiSource: OsmApiFeatureSource;
|
||||
|
||||
constructor(hash: UIEventSource<string>,
|
||||
|
@ -60,7 +60,9 @@ export default class SelectedFeatureHandler {
|
|||
if(hash === undefined || SelectedFeatureHandler._no_trigger_on.indexOf(hash) >= 0){
|
||||
return; // No valid feature selected
|
||||
}
|
||||
// We should have a valid osm-ID and zoom to it
|
||||
// We should have a valid osm-ID and zoom to it... But we wrap it in try-catch to be sure
|
||||
try{
|
||||
|
||||
OsmObject.DownloadObject(hash).addCallbackAndRunD(element => {
|
||||
const centerpoint = element.centerpoint();
|
||||
console.log("Zooming to location for select point: ", centerpoint)
|
||||
|
@ -68,6 +70,9 @@ export default class SelectedFeatureHandler {
|
|||
location.data.lon = centerpoint[1]
|
||||
location.ping();
|
||||
})
|
||||
}catch(e){
|
||||
console.error("Could not download OSM-object with id", hash, " - probably a weird hash")
|
||||
}
|
||||
}
|
||||
|
||||
private downloadFeature(hash: string){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue