in ark-demo/webapp/src/utils/htmlForFeature.js [23:69]
export default function htmlForFeature({
title,
feature,
formatter = DEFAULT_FORMATTER,
includeColumns = '*',
showColumnName = true,
}) {
if (!feature) {
throw new Error(`htmlForFeature needs "info.object" information`);
}
const propertyNames = Object.keys(feature.properties);
if (
formatter?.type &&
formatter?.columns &&
!isFormatterValid(propertyNames, formatter)
) {
return;
}
if (!includedColumnsAreValid(propertyNames, includeColumns)) {
return;
}
let html = '';
if (title) {
html = `<h3 style="margin: 0"><strong>${title}</strong></h3>`;
}
for (const name of propertyNames) {
if (
name !== 'layerName' &&
(includeColumns.includes(name) || includeColumns === '*')
) {
if (formatter?.columns.includes(name)) {
const formatterFunction = formatterFunctions[formatter.type];
html = generateHtml(feature, name, showColumnName, html, formatterFunction);
} else {
html = generateHtml(feature, name, showColumnName, html);
}
}
}
return html;
}