简化地图

This commit is contained in:
CN-JS-HuiBai
2026-04-05 01:34:39 +08:00
parent 672ea11598
commit e66905e57f
2 changed files with 34 additions and 46 deletions

View File

@@ -13,7 +13,6 @@
rel="stylesheet"> rel="stylesheet">
<link rel="stylesheet" href="/css/style.css"> <link rel="stylesheet" href="/css/style.css">
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts-gl@2.0.9/dist/echarts-gl.min.js"></script>
<script> <script>
// Prevent theme flicker // Prevent theme flicker
(function () { (function () {
@@ -245,7 +244,7 @@
<circle cx="12" cy="12" r="10" /> <circle cx="12" cy="12" r="10" />
<path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" /> <path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />
</svg> </svg>
全球服务器分布 (3D Map) 全球服务器分布
</h2> </h2>
</div> </div>
<div class="globe-body" id="globeContainer"></div> <div class="globe-body" id="globeContainer"></div>

View File

@@ -92,7 +92,7 @@
let currentSourceFilter = 'all'; let currentSourceFilter = 'all';
let currentPage = 1; let currentPage = 1;
let pageSize = 20; let pageSize = 20;
let myMap3D = null; let myMap2D = null;
// ---- Initialize ---- // ---- Initialize ----
function init() { function init() {
@@ -106,7 +106,7 @@
networkChart = new AreaChart(dom.networkCanvas); networkChart = new AreaChart(dom.networkCanvas);
// Initial map // Initial map
initMap3D(); initMap2D();
// Event listeners // Event listeners
dom.btnSettings.addEventListener('click', openSettings); dom.btnSettings.addEventListener('click', openSettings);
@@ -360,12 +360,12 @@
} }
} }
// ---- Global 3D Map ---- // ---- Global 2D Map ----
async function initMap3D() { async function initMap2D() {
if (!dom.globeContainer) return; if (!dom.globeContainer) return;
if (typeof echarts === 'undefined') { if (typeof echarts === 'undefined') {
console.warn('[Map3D] ECharts library not loaded.'); console.warn('[Map2D] ECharts library not loaded.');
dom.globeContainer.innerHTML = `<div class="chart-empty">地图库加载失败</div>`; dom.globeContainer.innerHTML = `<div class="chart-empty">地图库加载失败</div>`;
return; return;
} }
@@ -376,7 +376,7 @@
const worldJSON = await resp.json(); const worldJSON = await resp.json();
echarts.registerMap('world', worldJSON); echarts.registerMap('world', worldJSON);
myMap3D = echarts.init(dom.globeContainer); myMap2D = echarts.init(dom.globeContainer);
const option = { const option = {
backgroundColor: 'transparent', backgroundColor: 'transparent',
@@ -400,68 +400,57 @@
`; `;
} }
}, },
geo3D: { geo: {
map: 'world', map: 'world',
shading: 'lambert', roam: true,
environment: 'transparent', emphasis: {
light: { label: { show: false },
main: { intensity: 1.2, shadow: true, alpha: 45, beta: 45 }, itemStyle: { areaColor: '#2d334d' }
ambient: { intensity: 0.3 }
},
viewControl: {
autoRotate: true,
autoRotateSpeed: 5,
distance: 80,
alpha: 40,
beta: 0
}, },
itemStyle: { itemStyle: {
color: '#1a1d2d', areaColor: '#1a1d2d',
opacity: 1, borderColor: '#2d334d',
borderWidth: 0.8, borderWidth: 1
borderColor: '#2d334d'
}, },
emphasis: { select: {
itemStyle: { color: '#2d334d' } itemStyle: { areaColor: '#2d334d' }
}, }
regions: []
}, },
series: [{ series: [{
type: 'scatter3D', type: 'effectScatter',
coordinateSystem: 'geo3D', coordinateSystem: 'geo',
symbol: 'circle', showEffectOn: 'render',
symbolSize: 8, rippleEffect: { brushType: 'stroke', scale: 4, period: 4 },
symbolSize: 6,
itemStyle: { itemStyle: {
color: '#06b6d4', color: '#06b6d4',
opacity: 0.8, shadowBlur: 10,
borderWidth: 0.5, shadowColor: '#06b6d4'
borderColor: '#fff'
}, },
label: { show: false },
data: [] data: []
}] }]
}; };
myMap3D.setOption(option); myMap2D.setOption(option);
window.addEventListener('resize', () => myMap3D.resize()); window.addEventListener('resize', () => myMap2D.resize());
if (allServersData.length > 0) { if (allServersData.length > 0) {
updateMap3D(allServersData); updateMap2D(allServersData);
} }
} catch (err) { } catch (err) {
console.error('[Map3D] Initialization failed:', err); console.error('[Map2D] Initialization failed:', err);
} }
} }
function updateMap3D(servers) { function updateMap2D(servers) {
if (!myMap3D) return; if (!myMap2D) return;
const geoData = servers const geoData = servers
.filter(s => s.lat && s.lng) .filter(s => s.lat && s.lng)
.map(s => ({ .map(s => ({
name: s.job, name: s.job,
value: [s.lng, s.lat, 2], // 2 is altitude value: [s.lng, s.lat],
job: s.job, job: s.job,
city: s.city, city: s.city,
country: s.country, country: s.country,
@@ -470,7 +459,7 @@
netTx: s.netTx netTx: s.netTx
})); }));
myMap3D.setOption({ myMap2D.setOption({
series: [{ data: geoData }] series: [{ data: geoData }]
}); });
@@ -515,7 +504,7 @@
renderFilteredServers(); renderFilteredServers();
// Update globe // Update globe
updateMap3D(data.servers || []); updateMap2D(data.servers || []);
// Flash animation // Flash animation
if (previousMetrics) { if (previousMetrics) {