diff --git a/.changeset/small-steaks-refuse.md b/.changeset/small-steaks-refuse.md new file mode 100644 index 0000000..6b14610 --- /dev/null +++ b/.changeset/small-steaks-refuse.md @@ -0,0 +1,5 @@ +--- +"@watergis/maplibre-gl-legend": patch +--- + +fix: add error handling when sprite@2x.png is not reachable diff --git a/packages/maplibre-gl-legend/src/lib/index.ts b/packages/maplibre-gl-legend/src/lib/index.ts index 4d39b3c..06126be 100644 --- a/packages/maplibre-gl-legend/src/lib/index.ts +++ b/packages/maplibre-gl-legend/src/lib/index.ts @@ -350,9 +350,11 @@ export class MaplibreLegendControl implements IControl { this.loadImage(`${styleUrl}@2x.png`), this.loadJson(`${styleUrl}.json`) ]); - await promise.then(([image, json]) => { - this.setSprite(image, json); - }); + await promise + .then(([image, json]) => { + this.setSprite(image, json); + }) + .catch((err) => console.error(err)); this.updateLegendControl(); map.off('idle', afterLoadListener); }