From 1aa5bbb73f1a1bccc3332694867fe84561e7f3ff Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Thu, 5 Mar 2026 21:46:29 +0800 Subject: [PATCH] feat: implement the PolyWeather frontend application with Leaflet map, city details panel, and Chart.js temperature trends. --- web/static/app.js | 62 ++--------------------------------------------- 1 file changed, 2 insertions(+), 60 deletions(-) diff --git a/web/static/app.js b/web/static/app.js index b3e75337..fa4c329e 100644 --- a/web/static/app.js +++ b/web/static/app.js @@ -40,7 +40,6 @@ let tempChart = null; const AUTO_REFRESH_MS = 60 * 60 * 1000; // 1 hour let selectedForecastDate = null; let nearbyLayerGroup = null; -let heatLayer = null; // ────────────────────────────────────────────────────────── // Map Setup @@ -68,22 +67,6 @@ function initMap() { nearbyLayerGroup = L.layerGroup().addTo(map); - // Initialize Heatmap layer (requires Leaflet.heat) - heatLayer = L.heatLayer([], { - radius: 160, // Large radius for field blending - blur: 50, // Lower blur for more defined radar-like edges - max: 1.0, // We will pass normalized intensities [0, 1] - gradient: { - 0.0: "#3b82f6", // Blue (Coldest in localized set) - 0.2: "#06b6d4", // Cyan - 0.4: "#10b981", // Green - 0.6: "#facc15", // Yellow - 0.8: "#f97316", // Orange - 1.0: "#ef4444", // Red (Hottest in localized set) - }, - opacity: 0.45, - }).addTo(map); - // Close panel and clear selection when clicking on empty map space map.on("click", () => { closePanel(); @@ -101,10 +84,8 @@ function updateMapVisibility() { // These are the "Ankara-style" local station markers if (zoom < 7) { if (map.hasLayer(nearbyLayerGroup)) map.removeLayer(nearbyLayerGroup); - if (heatLayer && map.hasLayer(heatLayer)) map.removeLayer(heatLayer); } else { if (!map.hasLayer(nearbyLayerGroup)) map.addLayer(nearbyLayerGroup); - if (heatLayer && !map.hasLayer(heatLayer)) map.addLayer(heatLayer); } // 2. Handle Primary City Markers (Major vs Minor) @@ -313,7 +294,8 @@ function renderNearbyStations(data) { let windHtml = ""; if (st.wind_dir != null) { const rot = (parseFloat(st.wind_dir) + 180) % 360; - const speed = st.wind_speed != null ? `${st.wind_speed}k` : ""; + const speedRaw = parseFloat(st.wind_speed); + const speed = !isNaN(speedRaw) ? `${speedRaw.toFixed(1)}k` : ""; windHtml = `