function generateHTMLlegend(targetMultipolygon) {
const formatNumber = d3Format.format(",");
const formattedPopulation = formatNumber(targetMultipolygon.adu22_sum);
const formattedDensity = formatNumber(targetMultipolygon.all22_mean);
const formattedAdultPopulation = formatNumber(targetMultipolygon.adu22_sum);
const formattedPopulationWithDensityCut = formatNumber(
targetMultipolygon.d400_sum
);
const roundedDensity = Math.round(targetMultipolygon.all22_mean);
const roundedAdultPopulation = Math.round(targetMultipolygon.adu22_sum);
const roundedPopulationWithDensityCut = Math.round(
targetMultipolygon.d400_sum
);
const htmlTemplate = `
<div>
<div>${polygonSVG}: Area covered by all emitters for population calculations</div>
<div><strong>Country of Emitters</strong>: ${targetMultipolygon.COUNTRY},</div>
<div><strong>Population</strong> (all22_sum): ${formattedPopulation} <em>the total population, 2022 estimates</em></div>
<div><strong>Density</strong> (all22_mean): ${roundedDensity} <em>average square km people per total population, 2022 estimates</em> </div>
<div><strong>Adult Population</strong> (adu22_sum): ${formattedAdultPopulation} <em>adult population, 2022 estimates</em> </div>
<div><strong>Population with Density Cut</strong> (d400_sum): ${formattedPopulationWithDensityCut} <em>adult population with a filter to remove dense square kilometers with more than 400 people, 2022 estimates</em> </div>
</div>
`;
return htmlTemplate;
return html`<div>
<img src="${polygonSVG}" alt="simple circle to represent map polygons"/>
<div><strong>Country</strong>: ${targetMultipolygon.COUNTRY},</div>
<div><strong>Population</strong> (all22_sum): ${targetMultipolygon.adu22_sum} <em>the total population, 2022 estimates</em></div>
<div><strong>Density</strong> (all22_mean): ${targetMultipolygon.all22_mean} <em>average square km pop per total population, 2022 estimates</em> </div>
<div><strong>Adult Population</strong> (adu22_sum): ${targetMultipolygon.all22_mean} <em>adult population, 2022 estimates</em> </div>
<div><strong>Population with Density Cut</strong> (d400_sum): ${targetMultipolygon.all22_mean} <em>adult population with a filter to remove dense square kilo meters with more than 400 people, 2022 estimates</em> </div>
</div>`;
}