diff --git a/api/weather.php b/api/weather.php new file mode 100644 index 0000000..49eb9d2 --- /dev/null +++ b/api/weather.php @@ -0,0 +1,54 @@ + \ No newline at end of file diff --git a/assets/css/custom.css b/assets/css/custom.css index 1cccb0a..1d9343c 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -108,4 +108,31 @@ html, body { right: 0; bottom: 0; border: none; /* Remove the debug border */ +} + +#controls { + position: absolute; + top: 20px; + left: 20px; + background: rgba(42, 42, 42, 0.8); + color: #fff; + padding: 15px; + border-radius: 8px; + font-family: sans-serif; + z-index: 10; + box-shadow: 0 2px 10px rgba(0,0,0,0.2); +} + +.control-group h3 { + margin-top: 0; + margin-bottom: 10px; + font-size: 16px; + border-bottom: 1px solid #555; + padding-bottom: 5px; +} + +.control-group label { + display: block; + margin-bottom: 5px; + cursor: pointer; } \ No newline at end of file diff --git a/assets/js/main.js b/assets/js/main.js index 84835d9..8f318e5 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -5,7 +5,6 @@ function initializeGlobe() { try { console.log('Initializing Cesium Viewer'); - // Initialize a Cesium Viewer with a map const viewer = new Cesium.Viewer('cesiumContainer', { imageryProvider: new Cesium.OpenStreetMapImageryProvider({ url : 'https://a.tile.openstreetmap.org/' @@ -25,7 +24,19 @@ function initializeGlobe() { viewer.scene.globe.depthTestAgainstTerrain = false; console.log('Cesium Viewer initialized successfully'); - + // Add Weather Layer + const weatherImageryProvider = new Cesium.UrlTemplateImageryProvider({ + url: `api/weather.php?layer=clouds_new&z={z}&x={x}&y={y}`, + credit: 'Weather data © OpenWeatherMap' + }); + const weatherLayer = viewer.imageryLayers.addImageryProvider(weatherImageryProvider); + weatherLayer.alpha = 0.6; + + // UI Controls + const weatherCheckbox = document.getElementById('weatherLayerCheckbox'); + weatherCheckbox.addEventListener('change', function() { + weatherLayer.show = this.checked; + }); // Function to load wildfire data const loadWildfireData = async () => { @@ -50,66 +61,11 @@ function initializeGlobe() { } catch (error) { console.error('Error loading wildfire data:', error); - // This catch block prevents the globe from crashing if the API fails. - } - }; - - // Function to load hurricane data - const loadHurricaneData = async () => { - try { - console.log('Fetching hurricane data...'); - // Use KmlDataSource for the KML data from the hurricanes API - const hurricaneDataSource = await Cesium.KmlDataSource.load('api/hurricanes.php', { - camera: viewer.camera, - canvas: viewer.canvas - }); - await viewer.dataSources.add(hurricaneDataSource); - console.log('Hurricane data source added to viewer.'); - } catch (error) { - console.error('Error loading hurricane data:', error); - } - }; - - // Function to load GFS data - const loadGfsData = async () => { - try { - console.log('Fetching GFS data...'); - const response = await fetch('api/gfs.php'); - if (!response.ok) { - throw new Error(`HTTP error! status: ${response.status}`); - } - const geojsonData = await response.json(); - console.log('GFS data fetched successfully.'); - - const gfsDataSource = new Cesium.GeoJsonDataSource(); - await gfsDataSource.load(geojsonData, { - stroke: Cesium.Color.BLUE.withAlpha(0.3), - fill: Cesium.Color.BLUE.withAlpha(0.3), - strokeWidth: 1 - }); - - // Simple heatmap-like styling for GFS points - gfsDataSource.entities.values.forEach(entity => { - const value = entity.properties.value.getValue(); - const color = Cesium.Color.fromHsl(0.6 - (value - 100000) / 2000 * 0.5, 1.0, 0.5).withAlpha(0.5); - entity.point = new Cesium.PointGraphics({ - color: color, - pixelSize: 5 - }); - }); - - viewer.dataSources.add(gfsDataSource); - console.log('GFS data source added to viewer.'); - - } catch (error) { - console.error('Error loading GFS data:', error); } }; // Load all data sources loadWildfireData(); - // loadHurricaneData(); - // loadGfsData(); } catch (error) { console.error('A critical error occurred while initializing the Cesium viewer:', error); diff --git a/config.php b/config.php new file mode 100644 index 0000000..1589fbf --- /dev/null +++ b/config.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/index.php b/index.php index fe48b4b..a187236 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,4 @@ + @@ -9,6 +10,14 @@
+
+
+

Layers

+ +
+