From f4125630150e0658558c5abe2eb0e52966e2be6f Mon Sep 17 00:00:00 2001 From: Chad Burt Date: Fri, 15 Sep 2023 12:40:19 -0700 Subject: [PATCH] Improvements to text legends --- .../client/src/dataLayers/legends/glLegends.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/client/src/dataLayers/legends/glLegends.ts b/packages/client/src/dataLayers/legends/glLegends.ts index 11f10f3bf..3e889443e 100644 --- a/packages/client/src/dataLayers/legends/glLegends.ts +++ b/packages/client/src/dataLayers/legends/glLegends.ts @@ -165,7 +165,7 @@ const SIGNIFICANT_PAINT_PROPS = [ "circle-opacity", ]; -const SIGNIFICANT_LAYOUT_PROPS = ["icon-image", "icon-size", "text-size"]; +const SIGNIFICANT_LAYOUT_PROPS = ["icon-image", "icon-size"]; /** * While building the legend, it is important to keep track of what style props @@ -620,9 +620,18 @@ export function getLegendForGLStyleLayers( } } + console.log("legend", legend); // TODO: if no panels have been added yet, try inserting a single symbol // legend as a fallback - return legend; + if (legend.panels.length === 0) { + console.log("no panels", legend); + return { + type: "SimpleGLLegend", + symbol: getSingleSymbolForVectorLayers(layers), + }; + } else { + return legend; + } } } @@ -729,7 +738,10 @@ function getPaintProp( if (representedProperties && representedProperties.has(propName)) { return defaultIfAlreadyRepresented; } - const type = propName.split("-")[0]; + let type = propName.split("-")[0]; + if (type === "text") { + type = "symbol"; + } if (propName in paint) { const value = paint[propName]; if (isExpression(value)) {