mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
feat(global): use geoEquirectangular
This commit is contained in:
parent
1306dbde80
commit
dba1528116
@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { countryCodeMapping } from "@/lib/geo";
|
import { countryCodeMapping } from "@/lib/geo";
|
||||||
import { geoEqualEarth, geoPath } from "d3-geo";
|
import { geoEquirectangular, geoPath } from "d3-geo";
|
||||||
import { AnimatePresence, m } from "framer-motion";
|
import { AnimatePresence, m } from "framer-motion";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@ -33,9 +33,10 @@ export function InteractiveMap({
|
|||||||
.map((code) => countryCodeMapping[code])
|
.map((code) => countryCodeMapping[code])
|
||||||
.filter((code) => code !== undefined);
|
.filter((code) => code !== undefined);
|
||||||
|
|
||||||
const projection = geoEqualEarth()
|
const projection = geoEquirectangular()
|
||||||
.scale(180)
|
.scale(140)
|
||||||
.translate([width / 2, height / 2]);
|
.translate([width / 2, height / 2])
|
||||||
|
.rotate([-12, 0, 0]);
|
||||||
|
|
||||||
const path = geoPath().projection(projection);
|
const path = geoPath().projection(projection);
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ export function InteractiveMap({
|
|||||||
feature.properties.iso_a3,
|
feature.properties.iso_a3,
|
||||||
);
|
);
|
||||||
const countryCode = Object.entries(countryCodeMapping).find(
|
const countryCode = Object.entries(countryCodeMapping).find(
|
||||||
([,alpha3]) => alpha3 === feature.properties.iso_a3,
|
([, alpha3]) => alpha3 === feature.properties.iso_a3,
|
||||||
)?.[0];
|
)?.[0];
|
||||||
const serverCount = countryCode
|
const serverCount = countryCode
|
||||||
? serverCounts[countryCode] || 0
|
? serverCounts[countryCode] || 0
|
||||||
|
Loading…
Reference in New Issue
Block a user