Skip to content

Commit 9f10ee2

Browse files
committed
Fix year swapping issue
1 parent 6ca9afe commit 9f10ee2

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/composables/useMap.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,18 @@ watch(
7676
return
7777
}
7878

79-
// Skip reload when the effective (clamped) year hasn't changed (e.g. 2024 -> 2025)
8079
if (getEffectiveCloudlessYear(newYear) === getEffectiveCloudlessYear(oldYear)) {
81-
return
82-
}
80+
// Remove the old cloudless layer if it exists
81+
if (cloudlessLayer.value) {
82+
map.value.removeLayer(cloudlessLayer.value)
83+
}
8384

84-
// Remove the old cloudless layer if it exists
85-
if (cloudlessLayer.value) {
86-
map.value.removeLayer(cloudlessLayer.value)
87-
}
85+
// Create and add the new cloudless layer with the updated year
86+
cloudlessLayer.value = createCloudlessLayer(newYear)
8887

89-
// Create and add the new cloudless layer with the updated year
90-
cloudlessLayer.value = createCloudlessLayer(newYear)
91-
// Insert at index 0 to keep it as the base layer
92-
map.value.getLayers().insertAt(0, cloudlessLayer.value)
88+
// Insert at index 0 to keep it as the base layer
89+
map.value.getLayers().insertAt(0, cloudlessLayer.value)
90+
}
9391

9492
if (settings.value.mode === 'global') {
9593
if (globalPredictionsController.value) {

0 commit comments

Comments
 (0)