feat: Implement PolyWeather web application with FastAPI backend for weather data analysis and a Leaflet-based frontend.

This commit is contained in:
2569718930@qq.com
2026-03-05 18:02:11 +08:00
parent 37aaf1f909
commit e4a5be660f
3 changed files with 45 additions and 0 deletions
+28
View File
@@ -71,6 +71,33 @@ function initMap() {
map.on("click", () => {
closePanel();
});
// Handle zoom-based visibility for local stations and minor cities
map.on("zoomend", updateMapVisibility);
}
function updateMapVisibility() {
if (!map) return;
const zoom = map.getZoom();
// 1. Handle Nearby Individual Stations (very high zoom only)
// These are the "Ankara-style" local station markers
if (zoom < 7) {
if (map.hasLayer(nearbyLayerGroup)) map.removeLayer(nearbyLayerGroup);
} else {
if (!map.hasLayer(nearbyLayerGroup)) map.addLayer(nearbyLayerGroup);
}
// 2. Handle Primary City Markers (Major vs Minor)
Object.values(markers).forEach(({ marker, city }) => {
const isMajor = city.is_major !== false;
// Hide minor cities (like Ankara/Atlanta) when zoomed way out
if (zoom < 4 && !isMajor) {
if (map.hasLayer(marker)) map.removeLayer(marker);
} else {
if (!map.hasLayer(marker)) map.addLayer(marker);
}
});
}
// ──────────────────────────────────────────────────────────
@@ -109,6 +136,7 @@ function addCityMarkers(cities) {
});
document.getElementById("cityCount").textContent = cities.length;
updateMapVisibility();
}
function updateMarkerTemp(cityName, temp) {