diff --git a/public/js/app.js b/public/js/app.js index 996cc32..89aacc4 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -571,32 +571,29 @@ // Transform to Pacific-centered correctly const transformCoords = (coords) => { - if (!Array.isArray(coords)) return; - if (typeof coords[0] === 'number') return; // Point - if (typeof coords[0][0] === 'number') { // Ring - // Calculate average to decide if we should shift the whole ring + if (!Array.isArray(coords) || coords.length === 0) return; + const first = coords[0]; + if (!Array.isArray(first)) return; + + if (typeof first[0] === 'number') { // Ring let sum = 0; coords.forEach(pt => sum += pt[0]); let avg = sum / coords.length; if (avg < -20) { coords.forEach(pt => pt[0] += 360); } - // Fix internal wrap-around jumps to keep polygons contiguous - for (let i = 1; i < coords.length; i++) { - let prev = coords[i - 1][0]; - while (coords[i][0] - prev > 180) coords[i][0] -= 360; - while (coords[i][0] - prev < -180) coords[i][0] += 360; - } } else { coords.forEach(transformCoords); } }; - worldJSON.features.forEach(feature => { - if (feature.geometry && feature.geometry.coordinates) { - transformCoords(feature.geometry.coordinates); - } - }); + if (worldJSON && worldJSON.features) { + worldJSON.features.forEach(feature => { + if (feature.geometry && feature.geometry.coordinates) { + transformCoords(feature.geometry.coordinates); + } + }); + } echarts.registerMap('world', worldJSON); @@ -634,9 +631,9 @@ geo: { map: 'world', roam: true, - center: [160, 25], // Centered slightly better for global view + center: [165, 20], // Centered in Pacific zoom: 1.1, - aspectScale: 0.85, // Adjust aspect ratio to reduce vertical stretching in northern regions + aspectScale: 0.85, emphasis: { label: { show: false }, itemStyle: { areaColor: isLight ? '#f0f2f5' : '#2d334d' } @@ -682,11 +679,11 @@ myMap2D.setOption({ geo: { itemStyle: { - areaColor: isLight ? '#eef0f5' : '#1a1d2d', + areaColor: isLight ? '#f4f6fa' : '#1a1d2e', borderColor: isLight ? '#cbd5e1' : '#2d334d' }, emphasis: { - itemStyle: { areaColor: isLight ? '#f0f2f5' : '#2d334d' } + itemStyle: { areaColor: isLight ? '#f4f8ff' : '#2d334d' } } } });