fix(weather): paint overlay on mount instead of waiting for click

renderLayer was called during mounted() before selectedTime was seeded
from the dataset, so buildWeatherTileUrl returned null and no tile
layer was added. The overlay only appeared when the user clicked a
forecast hour and update_weather_overlay fired. Seed selectedTime
(and timelineData) from data attributes before the first renderLayer.
This commit is contained in:
Graham McIntire 2026-04-29 12:50:28 -05:00
parent db59815613
commit e632002255
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -436,6 +436,12 @@ export const WeatherMap: WeatherMapHook = {
this.pushEvent("select_layer", { layer: storedLayer })
}
// Seed selectedTime/timelineData from the dataset before the first
// renderLayer call. Without this, buildWeatherTileUrl returns null
// and no overlay paints until the user clicks a forecast button.
this.timelineData = JSON.parse(this.el.dataset.validTimes || "[]")
this.selectedTime = this.el.dataset.selectedTime || null
this.renderLayer()
this.handleEvent("update_weather_overlay", ({ selected }: { selected: string | null }) => {
@ -589,9 +595,9 @@ export const WeatherMap: WeatherMapHook = {
this.legend.addTo(this.map)
// --- Forecast timeline ---
// timelineData and selectedTime are seeded earlier (before the
// initial renderLayer); the timeline DOM hookup happens here.
this.timelineEl = document.getElementById("weather-forecast-timeline")
this.timelineData = JSON.parse(this.el.dataset.validTimes || "[]")
this.selectedTime = this.el.dataset.selectedTime || null
this.playbackTimer = null
this.timelineRenderedKey = ""