Merge pull request #632 from orangemug/fix/color-popup-swatch

Fix color in <FeatureLayerPopup/>
This commit is contained in:
Orange Mug 2020-04-04 15:48:35 +01:00 committed by GitHub
commit 45680151ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(color, propertySpec);
const val = exprResult.value.evaluate({
zoom: zoom
}, feature);
return val.toString();
}
else {
return color;
}
return String(color);
}
else {
// Default color
@ -84,7 +69,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";
}
}