Commit 21b98faf authored by Tomas Pettersson's avatar Tomas Pettersson 🏸
Browse files

keepTimeIndex

parent 1b473bee
......@@ -126,11 +126,8 @@ var L;
var validtimes = L.TimeDimension.Util.explodeTimeRange(new Date(allAvailableTimes[0]), new Date(allAvailableTimes[allAvailableTimes.length - 1]), 'PT15M');
if (filterAvailableTimes.length > 0)
validtimes = L.TimeDimension.Util.explodeTimeRange(new Date(filterAvailableTimes[0]), new Date(filterAvailableTimes[filterAvailableTimes.length - 1]), 'PT15M');
self.timeIndex = (self.timeIndex == 0) && self.timeDimension.getCurrentTimeIndex();
console.log(self.timeIndex);
self.timeDimension.setAvailableTimes(validtimes, 'replace');
self.timeDimension.setCurrentTimeIndex(keepTimeIndex && self.timeIndex > 0 && self.timeIndex || 0);
console.log(self.timeDimension.getCurrentTimeIndex());
self.timeDimension.setCurrentTimeIndex(keepTimeIndex && self.timeIndex || 0);
if (this.timeDimension._syncedLayers.length > 0) {
self.update({
date: +moment(self.timeDimension.getCurrentTime()).utc().format("X"),
......@@ -140,6 +137,7 @@ var L;
self.enable();
}
else {
self.timeIndex = self.timeDimension.getCurrentTimeIndex();
self.update({
date: +moment().utc().startOf("hour").format("X"),
min: +moment().utc().startOf("day").subtract(6, "hours").format("X"),
......
This diff is collapsed.
......@@ -146,11 +146,8 @@ export class Player extends L.Control {
if (filterAvailableTimes.length > 0)
validtimes = L.TimeDimension.Util.explodeTimeRange(new Date(filterAvailableTimes[0]),new Date(filterAvailableTimes[filterAvailableTimes.length-1]), 'PT15M');
self.timeIndex = (self.timeIndex == 0) && self.timeDimension.getCurrentTimeIndex();
console.log(self.timeIndex);
self.timeDimension.setAvailableTimes(validtimes, 'replace');
self.timeDimension.setCurrentTimeIndex(keepTimeIndex && self.timeIndex > 0 && self.timeIndex|| 0);
console.log(self.timeDimension.getCurrentTimeIndex());
self.timeDimension.setCurrentTimeIndex(keepTimeIndex && self.timeIndex || 0);
if (this.timeDimension._syncedLayers.length > 0) {
self.update({
......@@ -161,6 +158,7 @@ export class Player extends L.Control {
self.enable();
} else {
self.timeIndex = self.timeDimension.getCurrentTimeIndex();
self.update({
date: +moment().utc().startOf("hour").format("X"),
min: +moment().utc().startOf("day").subtract(6, "hours").format("X"),
......
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