diff --git a/api/wildfires.php b/api/wildfires.php new file mode 100644 index 0000000..b59c433 --- /dev/null +++ b/api/wildfires.php @@ -0,0 +1,41 @@ + 'Could not fetch wildfire data.']); + exit; +} + +$data = json_decode($response, true); + +if (json_last_error() !== JSON_ERROR_NONE) { + echo json_encode(['error' => 'Could not parse wildfire data.']); + exit; +} + +$features = $data['features'] ?? []; + +$wildfires = []; +foreach ($features as $feature) { + $properties = $feature['properties']; + $wildfires[] = [ + 'name' => $properties['poly_IncidentName'], + 'acres' => $properties['poly_Acres_AutoCalc'], + 'started' => $properties['attr_InitialResponseDateTime'], + 'percent_contained' => $properties['attr_PercentContained'], + ]; +} + +echo json_encode($wildfires); +?> \ No newline at end of file diff --git a/assets/css/custom.css b/assets/css/custom.css index 12a2da8..b7e55af 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -93,3 +93,11 @@ h2 { #cyclone-data .card { background-color: #F8F9FA; } + +#wildfire-widget { + background-color: #FFFFFF; +} + +#wildfire-data .card { + background-color: #F8F9FA; +} diff --git a/assets/js/main.js b/assets/js/main.js index 05cd30e..a53341e 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -69,4 +69,36 @@ document.addEventListener('DOMContentLoaded', function () { console.error('Error fetching cyclone data:', error); }); } + + // Fetch and display wildfire data + const wildfireDataContainer = document.getElementById('wildfire-data'); + if (wildfireDataContainer) { + fetch('api/wildfires.php') + .then(response => response.json()) + .then(data => { + if (data && data.length > 0) { + let html = ''; + data.forEach(fire => { + html += ` +
+
+
+
${fire.name}
+

${fire.acres ? Math.round(fire.acres) + ' acres' : 'Size not available'}

+

${fire.percent_contained !== null ? fire.percent_contained + '% contained' : 'Containment not available'}

+
+
+
+ `; + }); + wildfireDataContainer.innerHTML = html; + } else { + wildfireDataContainer.innerHTML = '

No active wildfires reported at the moment.

'; + } + }) + .catch(error => { + wildfireDataContainer.innerHTML = '

Could not load wildfire data. Please try again later.

'; + console.error('Error fetching wildfire data:', error); + }); + } }); diff --git a/index.php b/index.php index 09db81c..69b02b3 100644 --- a/index.php +++ b/index.php @@ -63,6 +63,13 @@ $hero_image_alt = $image_data ? $image_data['alt'] : 'Satellite view of a hurric +
+

Active Wildfires

+
+

Loading real-time wildfire data...

+
+
+

Technology & Innovation

Our innovative platform combines state-of-the-art AI models, big data analytics, and immersive visualization techniques to provide unparalleled insights into weather risks and climate patterns.