diff --git a/app/(main)/ClientComponents/InteractiveMap.tsx b/app/(main)/ClientComponents/InteractiveMap.tsx index bb1f069..abfae65 100644 --- a/app/(main)/ClientComponents/InteractiveMap.tsx +++ b/app/(main)/ClientComponents/InteractiveMap.tsx @@ -1,6 +1,5 @@ "use client"; -import { countryCodeMapping } from "@/lib/geo"; import { geoEquirectangular, geoPath } from "d3-geo"; import { AnimatePresence, m } from "framer-motion"; import { useTranslations } from "next-intl"; @@ -29,10 +28,6 @@ export function InteractiveMap({ count: number; } | null>(null); - const countries_alpha3 = countries - .map((code) => countryCodeMapping[code]) - .filter((code) => code !== undefined); - const projection = geoEquirectangular() .scale(140) .translate([width / 2, height / 2]) @@ -56,17 +51,15 @@ export function InteractiveMap({ {filteredFeatures.map((feature, index) => { - const isHighlighted = countries_alpha3.includes( - feature.properties.iso_a3_eh, + const isHighlighted = countries.includes( + feature.properties.iso_a2_eh, ); - const countryCode = Object.entries(countryCodeMapping).find( - ([, alpha3]) => alpha3 === feature.properties.iso_a3_eh, - )?.[0]; + if (isHighlighted) { + console.log(feature.properties.iso_a2_eh); + } - const serverCount = countryCode - ? serverCounts[countryCode] || 0 - : 0; + const serverCount = serverCounts[feature.properties.iso_a2_eh] || 0; return ( { - acc[alpha3] = alpha2; - return acc; - }, - {} as { [key: string]: string }, - ); - -/** - * 将 ISO 3166-1 alpha-2 (2位) 国家代码转换为 ISO 3166-1 alpha-3 (3位) 代码 - * @param alpha2 2位国家代码 - * @returns 3位国家代码,如果未找到匹配项则返回原始代码 - */ -export function convertToAlpha3(alpha2: string): string { - if (!alpha2) return ""; - - const code = alpha2.toUpperCase(); - return countryCodeMapping[code] || alpha2; -} - -/** - * 批量转换2位国家代码到3位国家代码 - * @param alpha2Codes 2位国家代码数组 - * @returns 3位国家代码数组 - */ -export function convertMultipleToAlpha3(alpha2Codes: string[]): string[] { - return alpha2Codes.map((code) => convertToAlpha3(code)); -}