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:
parent
db59815613
commit
e632002255
1 changed files with 8 additions and 2 deletions
|
|
@ -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 = ""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue