Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function updateStyle() {
const element = map.getTargetElement();
if (!element) {
return;
}
const layout = layer.layout || {};
const paint = layer.paint || {};
background['paint'] = paint;
background.id = 'olms-bg-' + paint['background-opacity'] + paint['background-color'];
const zoom = map.getView().getZoom();
if (paint['background-color'] !== undefined) {
const bg = getValue(background, 'paint', 'background-color', zoom, emptyObj);
element.style.backgroundColor = Color.parse(bg).toString();
}
if (paint['background-opacity'] !== undefined) {
element.style.opacity = getValue(background, 'paint', 'background-opacity', zoom, emptyObj);
}
if (layout.visibility == 'none') {
element.style.backgroundColor = '';
element.style.opacity = '';
}
}
if (map.getTargetElement()) {
let value = (layer[layoutOrPaint] || emptyObj)[property];
const propertySpec = spec[`${layoutOrPaint}_${layer.type}`][property];
if (value === undefined) {
value = propertySpec.default;
}
let isExpr = isExpression((value));
if (!isExpr && isFunction(value)) {
value = convertFunction(value, propertySpec);
isExpr = true;
}
if (isExpr) {
const compiledExpression = expressionData(value, propertySpec);
functions[property] = compiledExpression.evaluate.bind(compiledExpression);
} else {
if (propertySpec.type == 'color') {
value = Color.parse(value);
}
functions[property] = function() {
return value;
};
}
}
zoomObj.zoom = zoom;
return functions[property](zoomObj, feature);
}