diff --git a/package-lock.json b/package-lock.json index 6a14114c4..1e617218d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,7 @@ "typescript": "^4.9.5" }, "engines": { - "node": ">=18", + "node": ">=18 <=20", "npm": ">=8.3.0" } }, @@ -6300,7 +6300,7 @@ }, "shieldlib": { "name": "@americana/maplibre-shield-generator", - "version": "0.0.5", + "version": "0.0.7", "license": "CC0-1.0", "dependencies": { "@types/node": "^20.8.4", diff --git a/src/js/legend_control.js b/src/js/legend_control.js index 3ff1905a1..ff3a9063c 100644 --- a/src/js/legend_control.js +++ b/src/js/legend_control.js @@ -466,7 +466,10 @@ export default class LegendControl { let unrecognizedNetworks = new Set(); for (let image of images) { if (!(image.network in imagesByNetwork)) { - imagesByNetwork[image.network] = { overridesByRef: {} }; + imagesByNetwork[image.network] = { + overridesByRef: {}, + overridesByName: {}, + }; } let networkImages = imagesByNetwork[image.network]; @@ -476,6 +479,12 @@ export default class LegendControl { if (!networkImages.overridesByRef[image.ref]) { networkImages.overridesByRef[image.ref] = image.imageName; } + } else if (image.name && shieldDef?.overrideByName?.[image.name]) { + // Store a different image for each override in the shield definition. + if (!networkImages.overridesByName[image.name]) { + networkImages.overridesByName[image.name] = + shieldDef.overrideByName[image.name].spriteBlank; + } } else if (!networkImages.ref && image.ref) { // Store the numbered variant of a shield if required by the shield // definition. @@ -498,9 +507,10 @@ export default class LegendControl { let images = imagesByNetwork[network]; if (!images) return []; return [ - images.noRef, + Object.values(images.overridesByName).length > 0 ? "" : images.noRef, images.ref, ...Object.values(images.overridesByRef), + ...Object.values(images.overridesByName), ].filter((i) => i); };