Open popup of newly added element immediatly, fix #132
This commit is contained in:
parent
e16a210ee1
commit
a75471df77
2 changed files with 15 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
import {Img} from "../../UI/Img";
|
import {Img} from "../../UI/Img";
|
||||||
import {RegexTag, Tag} from "../../Logic/Tags";
|
import {RegexTag, Tag} from "../../Logic/Tags";
|
||||||
import {TagRenderingOptions} from "../TagRenderingOptions";
|
import {TagRenderingOptions} from "../TagRenderingOptions";
|
||||||
|
import {FixedUiElement} from "../../UI/Base/FixedUiElement";
|
||||||
|
|
||||||
|
|
||||||
export class OsmLink extends TagRenderingOptions {
|
export class OsmLink extends TagRenderingOptions {
|
||||||
|
@ -18,7 +19,7 @@ export class OsmLink extends TagRenderingOptions {
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
},
|
},
|
||||||
mappings: [
|
mappings: [
|
||||||
{k: new RegexTag("id", /node\/-.+/), txt: "<span class='alert'>Uploading</span>"}
|
{k: new RegexTag("id", /node\/-.+/), txt: ""}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,12 +165,11 @@ export class FilteredLayer {
|
||||||
|
|
||||||
public AddNewElement(element) {
|
public AddNewElement(element) {
|
||||||
this._newElements.push(element);
|
this._newElements.push(element);
|
||||||
console.log("Element added");
|
this.RenderLayer({features: this._dataFromOverpass}, element); // Update the layer
|
||||||
this.RenderLayer({features:this._dataFromOverpass}); // Update the layer
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private RenderLayer(data) {
|
private RenderLayer(data, openPopupOf = undefined) {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
if (this._geolayer !== undefined && this._geolayer !== null) {
|
if (this._geolayer !== undefined && this._geolayer !== null) {
|
||||||
|
@ -219,6 +218,7 @@ export class FilteredLayer {
|
||||||
// The points get a special treatment in order to render them properly
|
// The points get a special treatment in order to render them properly
|
||||||
// Note that some features might get a point representation as well
|
// Note that some features might get a point representation as well
|
||||||
|
|
||||||
|
const runWhenAdded: (() => void)[] = []
|
||||||
|
|
||||||
this._geolayer = L.geoJSON(data, {
|
this._geolayer = L.geoJSON(data, {
|
||||||
style: function (feature) {
|
style: function (feature) {
|
||||||
|
@ -252,7 +252,7 @@ export class FilteredLayer {
|
||||||
const popup = L.popup({}, marker);
|
const popup = L.popup({}, marker);
|
||||||
let uiElement: UIElement;
|
let uiElement: UIElement;
|
||||||
let content = undefined;
|
let content = undefined;
|
||||||
marker.bindPopup(popup)
|
let p = marker.bindPopup(popup)
|
||||||
.on("popupopen", () => {
|
.on("popupopen", () => {
|
||||||
if (content === undefined) {
|
if (content === undefined) {
|
||||||
uiElement = self._showOnPopup(eventSource, feature);
|
uiElement = self._showOnPopup(eventSource, feature);
|
||||||
|
@ -263,6 +263,12 @@ export class FilteredLayer {
|
||||||
uiElement.Update();
|
uiElement.Update();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (feature === openPopupOf) {
|
||||||
|
runWhenAdded.push(() => {
|
||||||
|
p.openPopup();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return marker;
|
return marker;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -321,6 +327,9 @@ export class FilteredLayer {
|
||||||
|
|
||||||
if (this.combinedIsDisplayed.data) {
|
if (this.combinedIsDisplayed.data) {
|
||||||
this._geolayer.addTo(State.state.bm.map);
|
this._geolayer.addTo(State.state.bm.map);
|
||||||
|
for (const f of runWhenAdded) {
|
||||||
|
f();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue