Small robustifications

This commit is contained in:
pietervdvn 2021-09-22 20:44:53 +02:00
parent 6566576201
commit b1900cdbc6
4 changed files with 22 additions and 14 deletions

View file

@ -154,6 +154,9 @@ export default class LayerConfig {
this.minzoom = json.minzoom ?? 0;
this.minzoomVisible = json.minzoomVisible ?? this.minzoom;
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) => {
let preciseInput = undefined;
@ -492,8 +495,8 @@ export default class LayerConfig {
const iconUrlStatic = render(this.icon);
const self = this;
function genHtmlFromString(sourcePart: string, rotation: string): BaseUIElement {
const style = `width:100%;height:100%;transform: rotate( ${rotation} );display:block;position: absolute; top: 0; left: 0`;
function genHtmlFromString(sourcePart: string, rotation: string, style?: string): BaseUIElement {
style = style ?? `width:100%;height:100%;transform: rotate( ${rotation} );display:block;position: absolute; top: 0; left: 0`;
let html: BaseUIElement = new FixedUiElement(
`<img src="${sourcePart}" style="${style}" />`
);
@ -537,7 +540,7 @@ export default class LayerConfig {
.filter((prt) => prt != "");
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(

View file

@ -50,7 +50,7 @@ export default class MinimapImplementation extends BaseUIElement implements Mini
if (typeof factor === "number") {
bounds = leaflet.getBounds()
leaflet.setMaxBounds(bounds.pad(factor))
}else{
} else {
// @ts-ignore
leaflet.setMaxBounds(factor.toLeaflet())
bounds = leaflet.getBounds()
@ -114,8 +114,12 @@ export default class MinimapImplementation extends BaseUIElement implements Mini
const self = this;
// @ts-ignore
const resizeObserver = new ResizeObserver(_ => {
self.InitMap();
self.leafletMap?.data?.invalidateSize()
try {
self.InitMap();
self.leafletMap?.data?.invalidateSize()
} catch (e) {
console.error("Could not construct a minimap:", e)
}
});
resizeObserver.observe(div);
@ -141,8 +145,12 @@ export default class MinimapImplementation extends BaseUIElement implements Mini
const location = this._location;
const self = this;
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 = {
center: <[number, number]>[location.data?.lat ?? 0, location.data?.lon ?? 0],
center: latLon,
zoom: location.data?.zoom ?? 2,
layers: [currentLayer],
zoomControl: false,

View file

@ -538,7 +538,9 @@
}
},
{
"if": "amenity=charging_station",
"if": {
"and": ["amenity=charging_station","operational_status="]
},
"then": {
"en": "This charging station works",
"nl": "Dit oplaadpunt werkt"

View file

@ -213,12 +213,7 @@
"then": "#ff0"
}
]
},
"presets": [
{
}
]
}
},
{
"id": "named_streets",