Fix: loading oneway arrows on multiple layers; fix nullpointer
This commit is contained in:
parent
c823e745a3
commit
16784270ce
2 changed files with 20 additions and 11 deletions
|
@ -312,7 +312,7 @@ export default class PointRenderingConfig extends WithContextLoader {
|
||||||
if (cssLabel) {
|
if (cssLabel) {
|
||||||
label.SetStyle(cssLabel)
|
label.SetStyle(cssLabel)
|
||||||
} else if (labelOnly) {
|
} else if (labelOnly) {
|
||||||
return label.SetStyle("transform: translate(-50%, -50%);")
|
return label?.SetStyle("transform: translate(-50%, -50%);")
|
||||||
}
|
}
|
||||||
return new Combine([label]).SetClass("flex flex-col items-center")
|
return new Combine([label]).SetClass("flex flex-col items-center")
|
||||||
})
|
})
|
||||||
|
|
|
@ -235,17 +235,26 @@ class LineRenderingLayer {
|
||||||
map.on("styledata", () => self.update(features.features))
|
map.on("styledata", () => self.update(features.features))
|
||||||
}
|
}
|
||||||
|
|
||||||
private addSymbolLayer(sourceId: string, url: string = "./assets/png/oneway.png"){
|
private async addSymbolLayer(sourceId: string, url: string = "./assets/png/oneway.png") {
|
||||||
const map = this._map
|
const map = this._map
|
||||||
const imgId = url.replaceAll(/[/.-]/g, "_")
|
const imgId = url.replaceAll(/[/.-]/g, "_")
|
||||||
map.loadImage(url, (err, image) => {
|
|
||||||
if (err) {
|
if (map.getImage(imgId) === undefined) {
|
||||||
console.error("Could not add symbol layer to line due to", err);
|
await new Promise<void>((resolve, reject) => {
|
||||||
return
|
map.loadImage(url, (err, image) => {
|
||||||
}
|
if (err) {
|
||||||
map.addImage(imgId, image);
|
console.error("Could not add symbol layer to line due to", err)
|
||||||
map.addLayer({
|
reject(err)
|
||||||
'id': "symbol-layer"+imgId,
|
return
|
||||||
|
}
|
||||||
|
map.addImage(imgId, image)
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
map.addLayer({
|
||||||
|
"id": "symbol-layer_" + this._layername + "-" + imgId,
|
||||||
'type': 'symbol',
|
'type': 'symbol',
|
||||||
'source': sourceId,
|
'source': sourceId,
|
||||||
'layout': {
|
'layout': {
|
||||||
|
@ -259,7 +268,7 @@ class LineRenderingLayer {
|
||||||
'visibility': 'visible'
|
'visibility': 'visible'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public destruct(): void {
|
public destruct(): void {
|
||||||
|
|
Loading…
Reference in a new issue