Real-time dashboard for monitoring global news, markets, and geopolitical events
TypeScript
Fix overlay alignment using D3 projection + expand map
Reggie4502496cb81f
diff --git a/index.html b/index.htmlindex 8f88c98..13324c4 100644--- a/index.html+++ b/index.html@@ -471,7 +471,7 @@/* Global Map - Situation Room Style */.world-map {width: 100%;- height: 400px;+ height: 550px;position: relative;background: #020a08;overflow: hidden;@@ -520,7 +520,7 @@.coord-label {position: absolute;- font-size: 0.5rem;+ font-size: 0.55rem;color: #0f6040;font-family: 'SF Mono', monospace;pointer-events: none;@@ -528,12 +528,10 @@}.coord-label.lat {- left: 5px;transform: translateY(-50%);}.coord-label.lon {- bottom: 3px;transform: translateX(-50%);}@@ -1882,16 +1880,18 @@const container = document.getElementById('worldMapContainer');const svg = d3.select('#worldMapSVG');const width = container.offsetWidth || 800;- const height = container.offsetHeight || 400;+ const height = container.offsetHeight || 550;svg.attr('width', '100%').attr('height', '100%').attr('viewBox', `0 0 ${width} ${height}`)- .attr('preserveAspectRatio', 'xMidYMid slice');+ .attr('preserveAspectRatio', 'none');- // Create projection (equirectangular)+ // Create projection that fills the entire container+ // Scale to fit width, center verticallyconst projection = d3.geoEquirectangular().scale(width / (2 * Math.PI))+ .center([0, 0]).translate([width / 2, height / 2]);const path = d3.geoPath().projection(projection);@@ -1946,18 +1946,6 @@.attr('stroke-width', 0.5).attr('stroke-opacity', 0.5);- // Add equator and prime meridian- svg.append('line')- .attr('x1', 0).attr('y1', height / 2)- .attr('x2', width).attr('y2', height / 2)- .attr('stroke', '#0f4035')- .attr('stroke-width', 1);- svg.append('line')- .attr('x1', width / 2).attr('y1', 0)- .attr('x2', width / 2).attr('y2', height)- .attr('stroke', '#0f4035')- .attr('stroke-width', 1);-// Load and render countriesconst world = await loadWorldMap();if (world) {@@ -1974,28 +1962,36 @@.attr('stroke-width', 0.5);}+ // Helper to convert lon/lat to percentage using the projection+ const toPercent = (lon, lat) => {+ const [x, y] = projection([lon, lat]);+ return {+ x: (x / width) * 100,+ y: (y / height) * 100+ };+ };+// Build overlay HTMLlet overlaysHTML = '';// Coordinate labels[-60, -30, 0, 30, 60].forEach(lat => {- const yPercent = ((90 - lat) / 180) * 100;+ const pos = toPercent(-175, lat);const label = lat === 0 ? '0°' : (lat > 0 ? `${lat}°N` : `${Math.abs(lat)}°S`);- overlaysHTML += `<div class="coord-label lat" style="top: ${yPercent}%">${label}</div>`;+ overlaysHTML += `<div class="coord-label lat" style="top: ${pos.y}%; left: 0.5%;">${label}</div>`;});- [-120, -60, 0, 60, 120, 180].forEach(lon => {- const xPercent = ((lon + 180) / 360) * 100;+ [-120, -60, 0, 60, 120].forEach(lon => {+ const pos = toPercent(lon, -85);const label = lon === 0 ? '0°' : (lon > 0 ? `${lon}°E` : `${Math.abs(lon)}°W`);- overlaysHTML += `<div class="coord-label lon" style="left: ${xPercent}%">${label}</div>`;+ overlaysHTML += `<div class="coord-label lon" style="left: ${pos.x}%; bottom: 1%;">${label}</div>`;});// Cyber threat zonesconst cyberActive = Math.random() > 0.5;CYBER_REGIONS.forEach(cz => {- const xPercent = ((cz.lon + 180) / 360) * 100;- const yPercent = ((90 - cz.lat) / 180) * 100;+ const pos = toPercent(cz.lon, cz.lat);overlaysHTML += `- <div class="cyber-zone ${cyberActive ? 'active' : ''}" style="left: ${xPercent}%; top: ${yPercent}%;">+ <div class="cyber-zone ${cyberActive ? 'active' : ''}" style="left: ${pos.x}%; top: ${pos.y}%;"><div class="cyber-icon"></div><div class="cyber-label">${cz.group}</div></div>@@ -2004,11 +2000,10 @@// Shipping chokepointsSHIPPING_CHOKEPOINTS.forEach(cp => {- const xPercent = ((cp.lon + 180) / 360) * 100;- const yPercent = ((90 - cp.lat) / 180) * 100;+ const pos = toPercent(cp.lon, cp.lat);const isAlert = shippingAlerts.some(a => cp.keywords.some(k => a.toLowerCase().includes(k)));overlaysHTML += `- <div class="chokepoint ${isAlert ? 'alert' : ''}" style="left: ${xPercent}%; top: ${yPercent}%;">+ <div class="chokepoint ${isAlert ? 'alert' : ''}" style="left: ${pos.x}%; top: ${pos.y}%;"><div class="chokepoint-icon"></div><div class="chokepoint-label">${cp.name}</div></div>@@ -2016,12 +2011,11 @@});// Earthquake markers- earthquakes.slice(0, 8).forEach(eq => {- const xPercent = ((eq.lon + 180) / 360) * 100;- const yPercent = ((90 - eq.lat) / 180) * 100;+ earthquakes.slice(0, 10).forEach(eq => {+ const pos = toPercent(eq.lon, eq.lat);const isMajor = eq.mag >= 6.0;overlaysHTML += `- <div class="quake ${isMajor ? 'major' : ''}" style="left: ${xPercent}%; top: ${yPercent}%;">+ <div class="quake ${isMajor ? 'major' : ''}" style="left: ${pos.x}%; top: ${pos.y}%;"><div class="quake-icon"></div><div class="quake-label">M${eq.mag.toFixed(1)}</div></div>@@ -2031,10 +2025,9 @@// Intel hotspotsINTEL_HOTSPOTS.forEach(spot => {const activity = activityData[spot.id] || { level: 'low', score: 0 };- const xPercent = ((spot.lon + 180) / 360) * 100;- const yPercent = ((90 - spot.lat) / 180) * 100;+ const pos = toPercent(spot.lon, spot.lat);overlaysHTML += `- <div class="hotspot ${activity.level}" style="left: ${xPercent}%; top: ${yPercent}%;">+ <div class="hotspot ${activity.level}" style="left: ${pos.x}%; top: ${pos.y}%;"><div class="hotspot-dot"></div><div class="hotspot-label">${spot.name}