Map tab: much bigger map with its own remembered view
Publish Container / publish (push) Successful in 2m12s

- Map fills the screen (was a 56vh strip); timeline and details sit below it
- No longer snaps back to the main-page radar's location/zoom on every refresh or tab switch;
  starts as a wider regional view, remembers pan/zoom, and recentres only when the location changes
- New 'My location' button

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Nate EmmertandClaude Sonnet 5.5 committed 2026-10-15 13:43:04 -04:00
1 parent acdcd6a2c5
commit 4f47d67a7e
4 files changed
+49 -5

No files matched your search

+28
View File
@@ -378,6 +378,33 @@ function updateRadar(city, outlook) {
if (map.isStyleLoaded()) apply(); else map.once('idle', apply);
}
// ── Map tab: independent, remembered view (not tied to the main-page radar) ──
let mapCenteredFor = null;
const mapCityKey = (c) => `${(+c.latitude).toFixed(2)},${(+c.longitude).toFixed(2)}`;
function centerMap(city, force) {
const m = typeof mapsOverview !== 'undefined' ? mapsOverview?.map : null;
if (!m || city?.latitude == null) return;
const key = mapCityKey(city);
if (!force && mapCenteredFor === key) return; // keep wherever the user panned/zoomed to
let saved = null;
try { saved = JSON.parse(localStorage.getItem('mapView') || 'null'); } catch {}
if (!force && !mapCenteredFor && saved && saved.key === key && Number.isFinite(saved.zoom)) m.jumpTo({ center: [saved.lng, saved.lat], zoom: saved.zoom });
else mapsOverview.panTo(city.latitude, city.longitude, force ? 7 : 5); // wider regional view than the main-page radar
mapCenteredFor = key;
}
(() => {
const m = typeof mapsOverview !== 'undefined' ? mapsOverview?.map : null;
if (!m) return;
let t = 0;
m.on('moveend', () => {
if (!mapCenteredFor) return;
clearTimeout(t);
t = setTimeout(() => { try { const c = m.getCenter(); localStorage.setItem('mapView', JSON.stringify({ key: mapCenteredFor, lng: c.lng, lat: c.lat, zoom: m.getZoom() })); } catch {} }, 400);
});
$('map-recenter-btn')?.addEventListener('click', () => { if (state.currentCity) centerMap(state.currentCity, true); });
})();
// ── Public hooks ─────────────────────────────────────────────────────────────
let lastOutlook = null;
window.AppUI = {
@@ -399,6 +426,7 @@ window.AppUI = {
if (state.currentAir) renderAqi(state.currentAir);
if (stationFresh) renderStationContext();
},
centerMap,
onAir(air) { renderAqi(air); },
refreshFx() { const c = $('sky-fx'); if (c && fx.kind) { cancelAnimationFrame(fx.raf); fxResize(c); fxSeed(fx.kind); if (fx.parts.length) fxFrame(performance.now()); } },
onStation() { syncTopbarLocation(); renderStationContext(); },