시설용량 천단위 콤마

This commit is contained in:
yschoi
2025-08-11 09:34:05 +09:00
parent d86d0b0fca
commit bde50388d1
+17 -6
View File
@@ -73,6 +73,17 @@ const Map = () => {
fetchData();
}, []);
function formatWithCommas(value: any) {
if (value === null || value === undefined) return value;
const num = Number(value);
return isNaN(num) ? value : num.toLocaleString();
}
function formatDateString(dateStr: string) {
if (typeof dateStr !== "string" || dateStr.length !== 8) return dateStr;
return `${dateStr.slice(0, 4)}-${dateStr.slice(4, 6)}-${dateStr.slice(6)}`;
}
// ===== 오버레이 콘텐츠 빌더 =====
const buildOverlayContent = (layerType: string, feature: FeatureData) => {
const props: Record<string, any> = {};
@@ -84,9 +95,9 @@ const Map = () => {
if (layerType === "tb_il_swage_prcs_fclt") {
// 하수처리시설
props["하수처리시설명"] = mayGet("swtrmt_fclt_nm");
props["시설용량(m³/d)"] = mayGet("fclt_cpct");
props["시설용량(m³/d)"] = formatWithCommas(mayGet("fclt_cpct"));
props["주소"] = mayGet("rdnm_addr");
props["가동개시일"] = mayGet("oprtng_strt_ymd");
props["가동개시일"] = formatDateString(mayGet("oprtng_strt_ymd"));
props["공법"] = mayGet("rprs_msrc_cn");
} else if (layerType === "tb_ms_swage_prcs_zone") {
// 처리구역(존)
@@ -116,14 +127,14 @@ const Map = () => {
<div class="font-semibold text-lg text-gray-800 mb-2 text-center bg-green-400">${title}</div>
<table class="w-full text-base text-gray-800">
${Object.entries(props)
.map(
([k, v]) => `
.map(
([k, v]) => `
<tr>
<td class="py-1 pr-2 text-gray-500 whitespace-nowrap">${k}</td>
<td class="py-1 font-medium">${safe(v)}</td>
</tr>`
)
.join("")}
)
.join("")}
</table>
`;
return el;