Commit a370c498 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸
Browse files

better clear when no layers

parent 55799be3
......@@ -94,15 +94,22 @@ var L;
validtimes = L.TimeDimension.Util.explodeTimeRange(new Date(filterAvailableTimes[0]), new Date(filterAvailableTimes[filterAvailableTimes.length - 1]), 'PT15M');
self.timeDimension.setAvailableTimes(validtimes, 'replace');
self.timeDimension.setCurrentTimeIndex(0);
self.update({
date: +moment(self.timeDimension.getCurrentTime()).utc().format("X"),
min: +moment(validtimes[0]).utc().format("X"),
max: +moment(validtimes[validtimes.length - 1]).utc().format("X"),
});
if (this.timeDimension._syncedLayers.length > 0)
if (this.timeDimension._syncedLayers.length > 0) {
self.update({
date: +moment(self.timeDimension.getCurrentTime()).utc().format("X"),
min: +moment(validtimes[0]).utc().format("X"),
max: +moment(validtimes[validtimes.length - 1]).utc().format("X"),
});
self.enable();
else
}
else {
self.update({
date: +moment().utc().startOf("hour").format("X"),
min: +moment().utc().startOf("day").subtract(6, "hours").format("X"),
max: +moment().utc().startOf("day").add(2, "days").format("X")
});
self.clear();
}
}
};
Player.prototype.clear = function () {
......
......@@ -114,15 +114,22 @@ export class Player extends L.Control {
self.timeDimension.setAvailableTimes(validtimes, 'replace');
self.timeDimension.setCurrentTimeIndex(0);
self.update({
date: +moment(self.timeDimension.getCurrentTime()).utc().format("X"),
min: +moment(validtimes[0]).utc().format("X"),
max: +moment(validtimes[validtimes.length - 1]).utc().format("X"),
});
if (this.timeDimension._syncedLayers.length > 0)
if (this.timeDimension._syncedLayers.length > 0) {
self.update({
date: +moment(self.timeDimension.getCurrentTime()).utc().format("X"),
min: +moment(validtimes[0]).utc().format("X"),
max: +moment(validtimes[validtimes.length - 1]).utc().format("X"),
});
self.enable();
else
} else {
self.update({
date: +moment().utc().startOf("hour").format("X"),
min: +moment().utc().startOf("day").subtract(6, "hours").format("X"),
max: +moment().utc().startOf("day").add(2,"days").format("X")
});
self.clear();
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment