Small robustifications
This commit is contained in:
parent
6566576201
commit
b1900cdbc6
4 changed files with 22 additions and 14 deletions
|
@ -154,6 +154,9 @@ export default class LayerConfig {
|
||||||
this.minzoom = json.minzoom ?? 0;
|
this.minzoom = json.minzoom ?? 0;
|
||||||
this.minzoomVisible = json.minzoomVisible ?? this.minzoom;
|
this.minzoomVisible = json.minzoomVisible ?? this.minzoom;
|
||||||
this.wayHandling = json.wayHandling ?? 0;
|
this.wayHandling = json.wayHandling ?? 0;
|
||||||
|
if(json.presets !== undefined && json.presets?.map === undefined){
|
||||||
|
throw "Presets should be a list of items (at "+context+")"
|
||||||
|
}
|
||||||
this.presets = (json.presets ?? []).map((pr, i) => {
|
this.presets = (json.presets ?? []).map((pr, i) => {
|
||||||
|
|
||||||
let preciseInput = undefined;
|
let preciseInput = undefined;
|
||||||
|
@ -492,8 +495,8 @@ export default class LayerConfig {
|
||||||
const iconUrlStatic = render(this.icon);
|
const iconUrlStatic = render(this.icon);
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
function genHtmlFromString(sourcePart: string, rotation: string): BaseUIElement {
|
function genHtmlFromString(sourcePart: string, rotation: string, style?: string): BaseUIElement {
|
||||||
const style = `width:100%;height:100%;transform: rotate( ${rotation} );display:block;position: absolute; top: 0; left: 0`;
|
style = style ?? `width:100%;height:100%;transform: rotate( ${rotation} );display:block;position: absolute; top: 0; left: 0`;
|
||||||
let html: BaseUIElement = new FixedUiElement(
|
let html: BaseUIElement = new FixedUiElement(
|
||||||
`<img src="${sourcePart}" style="${style}" />`
|
`<img src="${sourcePart}" style="${style}" />`
|
||||||
);
|
);
|
||||||
|
@ -537,7 +540,7 @@ export default class LayerConfig {
|
||||||
.filter((prt) => prt != "");
|
.filter((prt) => prt != "");
|
||||||
|
|
||||||
for (const badgePartStr of partDefs) {
|
for (const badgePartStr of partDefs) {
|
||||||
badgeParts.push(genHtmlFromString(badgePartStr, "0"));
|
badgeParts.push(genHtmlFromString(badgePartStr, "0", `width:unset;height:100%;display:block;`));
|
||||||
}
|
}
|
||||||
|
|
||||||
const badgeCompound = new Combine(badgeParts).SetStyle(
|
const badgeCompound = new Combine(badgeParts).SetStyle(
|
||||||
|
|
|
@ -50,7 +50,7 @@ export default class MinimapImplementation extends BaseUIElement implements Mini
|
||||||
if (typeof factor === "number") {
|
if (typeof factor === "number") {
|
||||||
bounds = leaflet.getBounds()
|
bounds = leaflet.getBounds()
|
||||||
leaflet.setMaxBounds(bounds.pad(factor))
|
leaflet.setMaxBounds(bounds.pad(factor))
|
||||||
}else{
|
} else {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
leaflet.setMaxBounds(factor.toLeaflet())
|
leaflet.setMaxBounds(factor.toLeaflet())
|
||||||
bounds = leaflet.getBounds()
|
bounds = leaflet.getBounds()
|
||||||
|
@ -114,8 +114,12 @@ export default class MinimapImplementation extends BaseUIElement implements Mini
|
||||||
const self = this;
|
const self = this;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const resizeObserver = new ResizeObserver(_ => {
|
const resizeObserver = new ResizeObserver(_ => {
|
||||||
self.InitMap();
|
try {
|
||||||
self.leafletMap?.data?.invalidateSize()
|
self.InitMap();
|
||||||
|
self.leafletMap?.data?.invalidateSize()
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Could not construct a minimap:", e)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
resizeObserver.observe(div);
|
resizeObserver.observe(div);
|
||||||
|
@ -141,8 +145,12 @@ export default class MinimapImplementation extends BaseUIElement implements Mini
|
||||||
const location = this._location;
|
const location = this._location;
|
||||||
const self = this;
|
const self = this;
|
||||||
let currentLayer = this._background.data.layer()
|
let currentLayer = this._background.data.layer()
|
||||||
|
let latLon = <[number, number]>[location.data?.lat ?? 0, location.data?.lon ?? 0]
|
||||||
|
if(isNaN(latLon[0]) || isNaN(latLon[1])){
|
||||||
|
latLon = [0,0]
|
||||||
|
}
|
||||||
const options = {
|
const options = {
|
||||||
center: <[number, number]>[location.data?.lat ?? 0, location.data?.lon ?? 0],
|
center: latLon,
|
||||||
zoom: location.data?.zoom ?? 2,
|
zoom: location.data?.zoom ?? 2,
|
||||||
layers: [currentLayer],
|
layers: [currentLayer],
|
||||||
zoomControl: false,
|
zoomControl: false,
|
||||||
|
|
|
@ -538,7 +538,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"if": "amenity=charging_station",
|
"if": {
|
||||||
|
"and": ["amenity=charging_station","operational_status="]
|
||||||
|
},
|
||||||
"then": {
|
"then": {
|
||||||
"en": "This charging station works",
|
"en": "This charging station works",
|
||||||
"nl": "Dit oplaadpunt werkt"
|
"nl": "Dit oplaadpunt werkt"
|
||||||
|
|
|
@ -213,12 +213,7 @@
|
||||||
"then": "#ff0"
|
"then": "#ff0"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
"presets": [
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "named_streets",
|
"id": "named_streets",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue