From df98cb9c7b528b7ac35ca01cd0f6493d980f083f Mon Sep 17 00:00:00 2001 From: orangemug Date: Sat, 4 Apr 2020 10:21:58 +0100 Subject: [PATCH 1/2] Fix layer color swatch in --- src/components/map/FeatureLayerPopup.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/map/FeatureLayerPopup.jsx b/src/components/map/FeatureLayerPopup.jsx index 550c335..ce434ab 100644 --- a/src/components/map/FeatureLayerPopup.jsx +++ b/src/components/map/FeatureLayerPopup.jsx @@ -66,7 +66,7 @@ class FeatureLayerPopup extends React.Component { color = styleFunction.convertFunction(color, propertySpec); } - const exprResult = expression.createExpression(color, propertySpec); + const exprResult = expression.createExpression(String(color), propertySpec); const val = exprResult.value.evaluate({ zoom: zoom }, feature); @@ -84,7 +84,7 @@ class FeatureLayerPopup extends React.Component { // This is quite complex, just incase there's an edgecase we're missing // always return black if we get an unexpected error. catch (err) { - console.error("Unable to get feature color, error:", err); + console.warn("Unable to get feature color, error:", err); return "black"; } } From bac8495b3cefd9c97344cf07c3530edf4a3bb3b3 Mon Sep 17 00:00:00 2001 From: orangemug Date: Sat, 4 Apr 2020 10:45:11 +0100 Subject: [PATCH 2/2] Made swatch simplier because colors from features are already evaluated --- src/components/map/FeatureLayerPopup.jsx | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/components/map/FeatureLayerPopup.jsx b/src/components/map/FeatureLayerPopup.jsx index ce434ab..6ee17ec 100644 --- a/src/components/map/FeatureLayerPopup.jsx +++ b/src/components/map/FeatureLayerPopup.jsx @@ -58,23 +58,8 @@ class FeatureLayerPopup extends React.Component { if(propName) { const propertySpec = latest["paint_"+feature.layer.type][propName]; - let color = feature.layer.paint[propName]; - - if(typeof(color) === "object") { - if(color.stops) { - color = styleFunction.convertFunction(color, propertySpec); - } - - const exprResult = expression.createExpression(String(color), propertySpec); - const val = exprResult.value.evaluate({ - zoom: zoom - }, feature); - return val.toString(); - } - else { - return color; - } + return String(color); } else { // Default color