Skip to content

Real-time dashboard for monitoring global news, markets, and geopolitical events

TypeScript

Use D3.js + TopoJSON for accurate world map borders

Reggie20d8f2c66470
diff --git a/index.html b/index.html
index 004720f..8f88c98 100644
--- a/index.html
+++ b/index.html
@@ -504,6 +504,20 @@
height: 100%;
}
+ .map-overlays {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ pointer-events: none;
+ z-index: 5;
+ }
+
+ .map-overlays > * {
+ pointer-events: auto;
+ }
+
.coord-label {
position: absolute;
font-size: 0.5rem;
@@ -1182,6 +1196,8 @@
}
}
</style>
+ <script src="https://d3js.org/d3.v7.min.js"></script>
+ <script src="https://cdn.jsdelivr.net/npm/topojson-client@3"></script>
</head>
<body>
<header class="header">
@@ -1830,35 +1846,168 @@
return results;
}
- // Render the global map - Situation Room Style
- function renderGlobalMap(activityData, earthquakes = [], shippingAlerts = []) {
+ // World map data cache
+ let worldMapData = null;
+
+ // Load world map TopoJSON data
+ async function loadWorldMap() {
+ if (worldMapData) return worldMapData;
+ try {
+ const response = await fetch('https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json');
+ worldMapData = await response.json();
+ return worldMapData;
+ } catch (e) {
+ console.error('Failed to load world map:', e);
+ return null;
+ }
+ }
+
+ // Render the global map - Situation Room Style with accurate borders
+ async function renderGlobalMap(activityData, earthquakes = [], shippingAlerts = []) {
const panel = document.getElementById('mapPanel');
+ const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 19) + ' UTC';
- let hotspotsHTML = '';
+ // Set up the container
+ panel.innerHTML = `
+ <div class="world-map" id="worldMapContainer">
+ <svg id="worldMapSVG"></svg>
+ <div class="map-overlays" id="mapOverlays"></div>
+ <div class="map-corner-label tl">GLOBAL ACTIVITY MONITOR</div>
+ <div class="map-corner-label tr">CLASSIFICATION: OPEN SOURCE</div>
+ <div class="map-corner-label bl">⚓ SHIPPING | 🔴 QUAKES | ◯ CYBER</div>
+ <div class="map-corner-label br">${timestamp}</div>
+ </div>
+ `;
- INTEL_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 container = document.getElementById('worldMapContainer');
+ const svg = d3.select('#worldMapSVG');
+ const width = container.offsetWidth || 800;
+ const height = container.offsetHeight || 400;
+
+ svg.attr('width', '100%')
+ .attr('height', '100%')
+ .attr('viewBox', `0 0 ${width} ${height}`)
+ .attr('preserveAspectRatio', 'xMidYMid slice');
+
+ // Create projection (equirectangular)
+ const projection = d3.geoEquirectangular()
+ .scale(width / (2 * Math.PI))
+ .translate([width / 2, height / 2]);
+
+ const path = d3.geoPath().projection(projection);
+
+ // Add background
+ svg.append('rect')
+ .attr('width', width)
+ .attr('height', height)
+ .attr('fill', '#020a08');
+
+ // Add grid pattern
+ const defs = svg.append('defs');
+
+ const smallGrid = defs.append('pattern')
+ .attr('id', 'smallGridD3')
+ .attr('width', 20)
+ .attr('height', 20)
+ .attr('patternUnits', 'userSpaceOnUse');
+ smallGrid.append('path')
+ .attr('d', 'M 20 0 L 0 0 0 20')
+ .attr('fill', 'none')
+ .attr('stroke', '#0a2a20')
+ .attr('stroke-width', 0.5);
+
+ const grid = defs.append('pattern')
+ .attr('id', 'gridD3')
+ .attr('width', 60)
+ .attr('height', 60)
+ .attr('patternUnits', 'userSpaceOnUse');
+ grid.append('rect')
+ .attr('width', 60)
+ .attr('height', 60)
+ .attr('fill', 'url(#smallGridD3)');
+ grid.append('path')
+ .attr('d', 'M 60 0 L 0 0 0 60')
+ .attr('fill', 'none')
+ .attr('stroke', '#0d3a2d')
+ .attr('stroke-width', 0.8);
+
+ svg.append('rect')
+ .attr('width', width)
+ .attr('height', height)
+ .attr('fill', 'url(#gridD3)');
+
+ // Add graticule (lat/lon lines)
+ const graticule = d3.geoGraticule().step([30, 30]);
+ svg.append('path')
+ .datum(graticule)
+ .attr('d', path)
+ .attr('fill', 'none')
+ .attr('stroke', '#0f4035')
+ .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 countries
+ const world = await loadWorldMap();
+ if (world) {
+ const countries = topojson.feature(world, world.objects.countries);
+
+ svg.append('g')
+ .selectAll('path')
+ .data(countries.features)
+ .enter()
+ .append('path')
+ .attr('d', path)
+ .attr('fill', '#0a2018')
+ .attr('stroke', '#0f5040')
+ .attr('stroke-width', 0.5);
+ }
- hotspotsHTML += `
- <div class="hotspot ${activity.level}" style="left: ${xPercent}%; top: ${yPercent}%;">
- <div class="hotspot-dot"></div>
- <div class="hotspot-label">
- ${spot.name}
- <div class="hotspot-info">${spot.subtext}</div>
- </div>
+ // Build overlay HTML
+ let overlaysHTML = '';
+
+ // Coordinate labels
+ [-60, -30, 0, 30, 60].forEach(lat => {
+ const yPercent = ((90 - lat) / 180) * 100;
+ const label = lat === 0 ? '0°' : (lat > 0 ? `${lat}°N` : `${Math.abs(lat)}°S`);
+ overlaysHTML += `<div class="coord-label lat" style="top: ${yPercent}%">${label}</div>`;
+ });
+ [-120, -60, 0, 60, 120, 180].forEach(lon => {
+ const xPercent = ((lon + 180) / 360) * 100;
+ const label = lon === 0 ? '0°' : (lon > 0 ? `${lon}°E` : `${Math.abs(lon)}°W`);
+ overlaysHTML += `<div class="coord-label lon" style="left: ${xPercent}%">${label}</div>`;
+ });
+
+ // Cyber threat zones
+ const cyberActive = Math.random() > 0.5;
+ CYBER_REGIONS.forEach(cz => {
+ const xPercent = ((cz.lon + 180) / 360) * 100;
+ const yPercent = ((90 - cz.lat) / 180) * 100;
+ overlaysHTML += `
+ <div class="cyber-zone ${cyberActive ? 'active' : ''}" style="left: ${xPercent}%; top: ${yPercent}%;">
+ <div class="cyber-icon"></div>
+ <div class="cyber-label">${cz.group}</div>
</div>
`;
});
// Shipping chokepoints
- let shippingHTML = '';
SHIPPING_CHOKEPOINTS.forEach(cp => {
const xPercent = ((cp.lon + 180) / 360) * 100;
const yPercent = ((90 - cp.lat) / 180) * 100;
const isAlert = shippingAlerts.some(a => cp.keywords.some(k => a.toLowerCase().includes(k)));
- shippingHTML += `
+ overlaysHTML += `
<div class="chokepoint ${isAlert ? 'alert' : ''}" style="left: ${xPercent}%; top: ${yPercent}%;">
<div class="chokepoint-icon"></div>
<div class="chokepoint-label">${cp.name}</div>
@@ -1867,12 +2016,11 @@
});
// Earthquake markers
- let quakeHTML = '';
earthquakes.slice(0, 8).forEach(eq => {
const xPercent = ((eq.lon + 180) / 360) * 100;
const yPercent = ((90 - eq.lat) / 180) * 100;
const isMajor = eq.mag >= 6.0;
- quakeHTML += `
+ overlaysHTML += `
<div class="quake ${isMajor ? 'major' : ''}" style="left: ${xPercent}%; top: ${yPercent}%;">
<div class="quake-icon"></div>
<div class="quake-label">M${eq.mag.toFixed(1)}</div>
@@ -1880,198 +2028,23 @@
`;
});
- // Cyber threat zones
- let cyberHTML = '';
- const cyberActive = Math.random() > 0.5; // Simulated - would come from real threat intel
- CYBER_REGIONS.forEach(cz => {
- const xPercent = ((cz.lon + 180) / 360) * 100;
- const yPercent = ((90 - cz.lat) / 180) * 100;
- cyberHTML += `
- <div class="cyber-zone ${cyberActive ? 'active' : ''}" style="left: ${xPercent}%; top: ${yPercent}%;">
- <div class="cyber-icon"></div>
- <div class="cyber-label">${cz.group}</div>
+ // Intel hotspots
+ INTEL_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;
+ overlaysHTML += `
+ <div class="hotspot ${activity.level}" style="left: ${xPercent}%; top: ${yPercent}%;">
+ <div class="hotspot-dot"></div>
+ <div class="hotspot-label">
+ ${spot.name}
+ <div class="hotspot-info">${spot.subtext}</div>
+ </div>
</div>
`;
});
- // Generate coordinate labels
- let coordLabels = '';
- // Latitude labels (every 30 degrees)
- [-60, -30, 0, 30, 60].forEach(lat => {
- const yPercent = ((90 - lat) / 180) * 100;
- const label = lat === 0 ? '0°' : (lat > 0 ? `${lat}°N` : `${Math.abs(lat)}°S`);
- coordLabels += `<div class="coord-label lat" style="top: ${yPercent}%">${label}</div>`;
- });
- // Longitude labels (every 60 degrees)
- [-120, -60, 0, 60, 120, 180].forEach(lon => {
- const xPercent = ((lon + 180) / 360) * 100;
- const label = lon === 0 ? '0°' : (lon > 0 ? `${lon}°E` : `${Math.abs(lon)}°W`);
- coordLabels += `<div class="coord-label lon" style="left: ${xPercent}%">${label}</div>`;
- });
-
- // Accurate world map SVG with country borders (equirectangular projection)
- const worldMapSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 180" preserveAspectRatio="none">
- <defs>
- <pattern id="smallGrid" width="10" height="10" patternUnits="userSpaceOnUse">
- <path d="M 10 0 L 0 0 0 10" fill="none" stroke="#0a2a20" stroke-width="0.3"/>
- </pattern>
- <pattern id="grid" width="30" height="30" patternUnits="userSpaceOnUse">
- <rect width="30" height="30" fill="url(#smallGrid)"/>
- <path d="M 30 0 L 0 0 0 30" fill="none" stroke="#0d3a2d" stroke-width="0.5"/>
- </pattern>
- </defs>
-
- <!-- Background -->
- <rect width="360" height="180" fill="#020a08"/>
-
- <!-- Grid -->
- <rect width="360" height="180" fill="url(#grid)"/>
-
- <!-- Major grid lines -->
- <g stroke="#0f4035" stroke-width="0.8">
- <line x1="0" y1="90" x2="360" y2="90"/>
- <line x1="180" y1="0" x2="180" y2="180"/>
- <line x1="0" y1="66.5" x2="360" y2="66.5" stroke-dasharray="2,2" opacity="0.5"/>
- <line x1="0" y1="113.5" x2="360" y2="113.5" stroke-dasharray="2,2" opacity="0.5"/>
- </g>
-
- <!-- Countries with borders -->
- <g fill="#0a2018" stroke="#0f5040" stroke-width="0.3">
- <!-- Russia -->
- <path d="M199,15 L205,17 L215,16 L225,18 L240,15 L255,17 L270,14 L285,16 L300,13 L315,15 L330,12 L345,14 L355,18 L360,20 L360,45 L355,48 L345,46 L330,50 L315,48 L300,52 L285,50 L270,53 L255,51 L245,54 L235,52 L225,55 L215,53 L205,56 L199,54 L195,50 L190,45 L192,40 L195,35 L192,30 L195,25 L199,20Z"/>
- <!-- Canada -->
- <path d="M15,25 L25,22 L35,24 L45,21 L55,23 L65,20 L75,22 L85,19 L95,21 L105,18 L115,20 L120,25 L125,30 L120,35 L115,40 L108,42 L100,40 L95,45 L88,43 L80,46 L72,44 L65,47 L58,45 L50,48 L42,46 L35,49 L28,47 L22,50 L15,48 L10,45 L8,40 L10,35 L8,30 L12,27Z"/>
- <!-- USA -->
- <path d="M22,50 L35,49 L50,48 L65,47 L80,46 L95,45 L100,48 L105,52 L100,55 L95,58 L88,56 L80,59 L72,57 L65,60 L58,58 L50,61 L42,59 L35,62 L28,60 L22,58 L18,55 L20,52Z"/>
- <!-- Alaska -->
- <path d="M5,35 L12,32 L18,35 L22,40 L18,45 L12,48 L5,45 L2,40Z"/>
- <!-- Mexico -->
- <path d="M35,62 L50,61 L58,64 L65,67 L62,72 L58,76 L52,78 L45,76 L40,72 L38,68 L35,65Z"/>
- <!-- Central America -->
- <path d="M52,78 L58,76 L62,80 L65,84 L62,88 L58,90 L55,88 L52,84 L50,80Z"/>
- <!-- Greenland -->
- <path d="M125,8 L135,5 L145,7 L152,12 L155,18 L152,25 L145,30 L138,32 L130,30 L125,25 L122,18 L125,12Z"/>
- <!-- Iceland -->
- <path d="M148,28 L155,26 L160,29 L158,33 L152,35 L148,32Z"/>
- <!-- UK -->
- <path d="M168,34 L172,32 L176,35 L178,40 L175,44 L170,46 L166,43 L165,38Z"/>
- <!-- Ireland -->
- <path d="M162,38 L166,36 L168,40 L166,44 L162,42Z"/>
- <!-- France -->
- <path d="M170,46 L178,44 L184,47 L186,52 L182,56 L176,58 L170,55 L168,50Z"/>
- <!-- Spain/Portugal -->
- <path d="M162,52 L170,50 L176,53 L178,58 L175,62 L168,64 L162,62 L160,57Z"/>
- <!-- Germany -->
- <path d="M178,40 L186,38 L192,42 L190,48 L184,50 L178,47Z"/>
- <!-- Poland -->
- <path d="M186,38 L195,36 L200,40 L198,46 L192,48 L186,45Z"/>
- <!-- Italy -->
- <path d="M182,52 L188,50 L192,54 L190,60 L186,64 L182,62 L180,57Z"/>
- <!-- Norway/Sweden -->
- <path d="M178,22 L185,18 L192,22 L195,30 L190,36 L184,38 L178,34 L176,28Z"/>
- <!-- Finland -->
- <path d="M192,20 L200,18 L205,24 L202,32 L196,34 L190,30Z"/>
- <!-- Ukraine -->
- <path d="M198,42 L210,40 L220,44 L218,50 L210,52 L200,50 L196,46Z"/>
- <!-- Turkey -->
- <path d="M198,52 L212,50 L225,53 L228,58 L222,62 L210,60 L200,58 L196,55Z"/>
- <!-- Saudi Arabia -->
- <path d="M210,60 L225,58 L235,62 L240,70 L235,78 L225,80 L215,76 L208,70 L210,64Z"/>
- <!-- Iran -->
- <path d="M225,53 L240,50 L252,55 L255,62 L250,70 L240,72 L230,68 L225,60Z"/>
- <!-- Iraq -->
- <path d="M212,55 L225,53 L230,60 L225,68 L215,70 L210,64Z"/>
- <!-- Egypt -->
- <path d="M198,58 L210,56 L215,62 L212,72 L205,78 L195,76 L192,68 L195,62Z"/>
- <!-- Libya -->
- <path d="M182,60 L198,58 L195,72 L192,82 L180,84 L175,76 L178,68Z"/>
- <!-- Algeria -->
- <path d="M168,60 L182,58 L185,68 L182,80 L170,82 L165,74 L166,66Z"/>
- <!-- Morocco -->
- <path d="M160,60 L170,58 L172,66 L168,74 L160,76 L156,70 L158,64Z"/>
- <!-- Mali/Niger region -->
- <path d="M168,76 L185,74 L192,82 L188,92 L175,94 L165,90 L166,82Z"/>
- <!-- Nigeria region -->
- <path d="M178,92 L192,90 L198,98 L195,108 L185,110 L175,106 L176,98Z"/>
- <!-- Ethiopia/Somalia -->
- <path d="M205,82 L220,78 L232,85 L230,98 L218,102 L205,98 L202,90Z"/>
- <!-- Congo/Central Africa -->
- <path d="M188,98 L205,96 L210,108 L205,120 L192,122 L182,118 L185,106Z"/>
- <!-- South Africa -->
- <path d="M188,122 L205,120 L212,132 L208,145 L195,148 L182,144 L180,132Z"/>
- <!-- India -->
- <path d="M248,55 L262,52 L275,58 L280,68 L278,80 L270,90 L258,92 L248,88 L242,78 L245,65Z"/>
- <!-- Pakistan -->
- <path d="M235,52 L250,48 L258,55 L255,65 L245,68 L238,62 L235,56Z"/>
- <!-- Afghanistan -->
- <path d="M238,48 L252,45 L260,50 L258,58 L250,60 L242,55Z"/>
- <!-- Kazakhstan -->
- <path d="M220,38 L245,35 L260,40 L258,48 L245,52 L230,50 L218,45Z"/>
- <!-- China -->
- <path d="M258,40 L280,36 L300,42 L315,48 L318,58 L312,68 L300,75 L285,78 L270,75 L260,68 L255,58 L258,48Z"/>
- <!-- Mongolia -->
- <path d="M265,35 L290,32 L305,38 L302,45 L288,48 L272,45 L265,40Z"/>
- <!-- Japan -->
- <path d="M318,42 L325,38 L330,42 L332,50 L328,58 L322,60 L318,55 L316,48Z"/>
- <!-- Korea -->
- <path d="M310,48 L318,45 L322,52 L320,60 L315,62 L310,58 L308,52Z"/>
- <!-- Taiwan -->
- <path d="M305,67 L310,65 L312,70 L308,74 L304,72Z"/>
- <!-- Philippines -->
- <path d="M305,78 L312,75 L318,82 L315,92 L308,94 L302,88 L304,82Z"/>
- <!-- Vietnam -->
- <path d="M285,68 L295,65 L300,75 L298,88 L292,92 L285,86 L283,76Z"/>
- <!-- Thailand -->
- <path d="M275,72 L288,70 L292,80 L288,92 L280,94 L272,88 L274,78Z"/>
- <!-- Myanmar -->
- <path d="M268,65 L280,62 L285,72 L282,82 L275,85 L268,78 L266,70Z"/>
- <!-- Malaysia -->
- <path d="M278,95 L292,92 L298,100 L294,106 L285,108 L278,102Z"/>
- <!-- Indonesia -->
- <path d="M280,105 L295,102 L310,108 L320,115 L318,122 L305,125 L290,122 L278,118 L275,112Z"/>
- <!-- Papua New Guinea -->
- <path d="M322,108 L335,105 L342,112 L338,120 L328,122 L320,118Z"/>
- <!-- Australia -->
- <path d="M295,118 L320,115 L340,122 L350,135 L348,150 L335,158 L315,160 L295,155 L280,145 L278,132 L285,122Z"/>
- <!-- New Zealand -->
- <path d="M352,148 L358,145 L362,152 L358,162 L352,165 L348,158Z"/>
- <!-- Brazil -->
- <path d="M68,85 L85,80 L100,88 L105,102 L100,118 L88,130 L72,132 L58,125 L55,110 L60,95Z"/>
- <!-- Argentina -->
- <path d="M60,125 L75,122 L82,135 L78,155 L68,168 L55,165 L52,150 L55,135Z"/>
- <!-- Chile -->
- <path d="M52,118 L60,115 L62,135 L58,160 L52,172 L48,165 L50,140 L48,125Z"/>
- <!-- Peru -->
- <path d="M52,88 L65,85 L70,98 L65,115 L55,118 L48,108 L50,95Z"/>
- <!-- Colombia -->
- <path d="M55,78 L70,75 L78,85 L75,95 L65,98 L55,92 L52,85Z"/>
- <!-- Venezuela -->
- <path d="M62,72 L78,70 L88,78 L85,88 L75,90 L65,86 L60,80Z"/>
- <!-- Cuba -->
- <path d="M60,68 L72,66 L78,70 L75,74 L65,76 L58,72Z"/>
- <!-- Caribbean -->
- <path d="M72,72 L82,70 L86,75 L82,80 L75,78Z"/>
- <!-- Antarctica hint -->
- <path d="M0,175 L360,175 L360,180 L0,180Z" fill="#0a2018" stroke="none"/>
- </g>
- </svg>`;
-
- const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 19) + ' UTC';
-
- panel.innerHTML = `
- <div class="world-map">
- ${worldMapSVG}
- ${cyberHTML}
- ${shippingHTML}
- ${quakeHTML}
- ${hotspotsHTML}
- ${coordLabels}
- <div class="map-corner-label tl">GLOBAL ACTIVITY MONITOR</div>
- <div class="map-corner-label tr">CLASSIFICATION: OPEN SOURCE</div>
- <div class="map-corner-label bl">⚓ SHIPPING | 🔴 QUAKES | ◯ CYBER</div>
- <div class="map-corner-label br">${timestamp}</div>
- </div>
- `;
+ document.getElementById('mapOverlays').innerHTML = overlaysHTML;
}
// Fetch Congressional trades - uses news RSS since APIs are locked down
@@ -3001,7 +2974,7 @@
t.toLowerCase().includes('hormuz') || t.toLowerCase().includes('houthi') ||
t.toLowerCase().includes('red sea') || t.toLowerCase().includes('shipping')
);
- renderGlobalMap(activityData, earthquakes, shippingAlerts);
+ await renderGlobalMap(activityData, earthquakes, shippingAlerts);
}
if (isPanelEnabled('mainchar')) {
const mainCharRankings = calculateMainCharacter(allNews);