Add guard to fix overlapping regional forecast icons after a period of time
This commit is contained in:
parent
31713abfaa
commit
a23eb483ea
1 changed files with 27 additions and 20 deletions
|
|
@ -21,6 +21,7 @@ class RegionalForecast extends WeatherDisplay {
|
||||||
this.locationMarker = null;
|
this.locationMarker = null;
|
||||||
this.nearbyMarkers = [];
|
this.nearbyMarkers = [];
|
||||||
this.nearbyMarkersKey = '';
|
this.nearbyMarkersKey = '';
|
||||||
|
this.refreshingMarkers = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData(weatherParameters, refresh) {
|
async getData(weatherParameters, refresh) {
|
||||||
|
|
@ -54,8 +55,11 @@ class RegionalForecast extends WeatherDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
async refreshNearbyMarkers() {
|
async refreshNearbyMarkers() {
|
||||||
if (!this.map || !this.active) return;
|
if (!this.map || !this.active || this.refreshingMarkers) return;
|
||||||
|
|
||||||
|
this.refreshingMarkers = true;
|
||||||
|
|
||||||
|
try {
|
||||||
this.map.invalidateSize(false);
|
this.map.invalidateSize(false);
|
||||||
this.map.setView([this.weatherParameters.latitude, this.weatherParameters.longitude], 6);
|
this.map.setView([this.weatherParameters.latitude, this.weatherParameters.longitude], 6);
|
||||||
|
|
||||||
|
|
@ -78,6 +82,9 @@ class RegionalForecast extends WeatherDisplay {
|
||||||
});
|
});
|
||||||
this.nearbyMarkers.forEach((marker) => marker.addTo(this.map));
|
this.nearbyMarkers.forEach((marker) => marker.addTo(this.map));
|
||||||
this.nearbyMarkersKey = markerKey;
|
this.nearbyMarkersKey = markerKey;
|
||||||
|
} finally {
|
||||||
|
this.refreshingMarkers = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async ensureMap() {
|
async ensureMap() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue