修复BUG
This commit is contained in:
@@ -568,12 +568,36 @@
|
||||
// Fetch map data
|
||||
const resp = await fetch('https://cdn.jsdelivr.net/npm/echarts@4.9.0/map/json/world.json');
|
||||
const worldJSON = await resp.json();
|
||||
|
||||
// Transform to Pacific-centered: shift longitudes < -20 to 340-360 range
|
||||
// This puts America on the right of Asia
|
||||
worldJSON.features.forEach(feature => {
|
||||
if (feature.geometry.type === 'Polygon') {
|
||||
feature.geometry.coordinates.forEach(ring => {
|
||||
ring.forEach(coords => {
|
||||
if (coords[0] < -20) coords[0] += 360;
|
||||
});
|
||||
});
|
||||
} else if (feature.geometry.type === 'MultiPolygon') {
|
||||
feature.geometry.coordinates.forEach(polygon => {
|
||||
polygon.forEach(ring => {
|
||||
ring.forEach(coords => {
|
||||
if (coords[0] < -20) coords[0] += 360;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
echarts.registerMap('world', worldJSON);
|
||||
|
||||
myMap2D = echarts.init(dom.globeContainer);
|
||||
|
||||
const isLight = document.documentElement.classList.contains('light-theme');
|
||||
|
||||
// Helper to transform app coordinates to shifted map coordinates
|
||||
const shiftLng = (lng) => (lng < -20 ? lng + 360 : lng);
|
||||
|
||||
const option = {
|
||||
backgroundColor: 'transparent',
|
||||
tooltip: {
|
||||
@@ -601,9 +625,11 @@
|
||||
geo: {
|
||||
map: 'world',
|
||||
roam: true,
|
||||
center: [165, 20], // Centered in Pacific
|
||||
zoom: 1.1,
|
||||
emphasis: {
|
||||
label: { show: false },
|
||||
itemStyle: { areaColor: isLight ? '#f0f2f5' : '#2d334d' }
|
||||
label: { show: false },
|
||||
itemStyle: { areaColor: isLight ? '#f0f2f5' : '#2d334d' }
|
||||
},
|
||||
itemStyle: {
|
||||
areaColor: isLight ? '#eef0f5' : '#1a1d2d',
|
||||
@@ -611,7 +637,7 @@
|
||||
borderWidth: 1
|
||||
},
|
||||
select: {
|
||||
itemStyle: { areaColor: isLight ? '#f0f2f5' : '#2d334d' }
|
||||
itemStyle: { areaColor: isLight ? '#f0f2f5' : '#2d334d' }
|
||||
}
|
||||
},
|
||||
series: [{
|
||||
@@ -658,11 +684,14 @@
|
||||
function updateMap2D(servers) {
|
||||
if (!myMap2D) return;
|
||||
|
||||
// Shift longitude for Pacific-centered view
|
||||
const shiftLng = (lng) => (lng < -20 ? lng + 360 : lng);
|
||||
|
||||
const geoData = servers
|
||||
.filter(s => s.lat && s.lng)
|
||||
.map(s => ({
|
||||
name: s.job,
|
||||
value: [s.lng, s.lat],
|
||||
value: [shiftLng(s.lng), s.lat],
|
||||
job: s.job,
|
||||
city: s.city,
|
||||
country: s.country,
|
||||
@@ -715,13 +744,21 @@
|
||||
(sv.country || '').toLowerCase() === lowerName ||
|
||||
(sv.city || '').toLowerCase() === lowerName
|
||||
);
|
||||
if (s && s.lng && s.lat) return [s.lng, s.lat];
|
||||
if (s && s.lng && s.lat) return [shiftLng(s.lng), s.lat];
|
||||
return null;
|
||||
};
|
||||
|
||||
const getShiftedCoords = (name) => {
|
||||
const c = countryCoords[(name || '').toLowerCase().trim()];
|
||||
if (c) return [shiftLng(c[0]), c[1]];
|
||||
const raw = getCoords(name);
|
||||
if (raw) return [shiftLng(raw[0]), raw[1]];
|
||||
return null;
|
||||
};
|
||||
|
||||
currentLatencies.forEach((route, index) => {
|
||||
const startCoords = getCoords(route.source);
|
||||
const endCoords = getCoords(route.dest);
|
||||
const startCoords = getShiftedCoords(route.source);
|
||||
const endCoords = getShiftedCoords(route.dest);
|
||||
|
||||
if (startCoords && endCoords) {
|
||||
finalSeries.push({
|
||||
|
||||
Reference in New Issue
Block a user