修复地图放大之后消失的BUG

This commit is contained in:
CN-JS-HuiBai
2026-04-06 00:15:04 +08:00
parent 97e87409b5
commit d4d2927963
2 changed files with 31 additions and 17 deletions

View File

@@ -185,10 +185,11 @@
dom.globeCard.classList.toggle('expanded');
dom.btnExpandGlobe.classList.toggle('active');
if (myMap2D) {
// Multiple resizes to handle animation frames
setTimeout(() => myMap2D.resize(), 50);
setTimeout(() => myMap2D.resize(), 150);
setTimeout(() => myMap2D.resize(), 400);
// Multiple resizes to handle animation phases and final layout
myMap2D.resize();
setTimeout(() => myMap2D.resize(), 100);
setTimeout(() => myMap2D.resize(), 300);
setTimeout(() => myMap2D.resize(), 600); // Final resize after animation
}
});
}
@@ -662,21 +663,30 @@
// Add latency routes if configured
if (currentLatencies && currentLatencies.length > 0) {
const countryCoords = {
'China': [116.4074, 39.9042],
'United States': [-95.7129, 37.0902],
'Japan': [138.2529, 36.2048],
'Singapore': [103.8198, 1.3521],
'Germany': [10.4515, 51.1657],
'United Kingdom': [-3.436, 55.3781],
'France': [2.2137, 46.2276],
'Hong Kong': [114.1694, 22.3193],
'Taiwan': [120.9605, 23.6978],
'Korea': [127.7669, 35.9078]
'china': [116.4074, 39.9042],
'united states': [-95.7129, 37.0902],
'us seattle': [-122.3321, 47.6062],
'seattle': [-122.3321, 47.6062],
'japan': [138.2529, 36.2048],
'singapore': [103.8198, 1.3521],
'germany': [10.4515, 51.1657],
'united kingdom': [-3.436, 55.3781],
'france': [2.2137, 46.2276],
'hong kong': [114.1694, 22.3193],
'taiwan': [120.9605, 23.6978],
'south korea': [127.7669, 35.9078],
'korea': [127.7669, 35.9078]
};
const getCoords = (name) => {
if (countryCoords[name]) return countryCoords[name];
const s = servers.find(sv => sv.countryName === name || sv.country === name);
const lowerName = (name || '').toLowerCase().trim();
if (countryCoords[lowerName]) return countryCoords[lowerName];
const s = servers.find(sv =>
(sv.countryName || '').toLowerCase() === lowerName ||
(sv.country || '').toLowerCase() === lowerName ||
(sv.city || '').toLowerCase() === lowerName
);
if (s && s.lng && s.lat) return [s.lng, s.lat];
return null;
};