Commit 616feaa8 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸
Browse files

keep time index

parent 787e0485
......@@ -105,7 +105,13 @@ var L;
Player.prototype.getTimeDimension = function () {
return this.timeDimension;
};
Player.prototype.refresh = function (keepPosition) {
Player.prototype.getCurrentTimeIndex = function () {
return this.timeDimension.getCurrentTimeIndex();
};
Player.prototype.setCurrentTimeIndex = function (index) {
return this.timeDimension.setCurrentTimeIndex(index);
};
Player.prototype.refresh = function (keepTimeIndex) {
var self = this;
if (self.timeDimension) {
var allAvailableTimes = [];
......@@ -120,8 +126,11 @@ 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');
var timeIndex = self.timeDimension.getCurrentTimeIndex();
console.log(self.timeDimension.getCurrentTimeIndex());
self.timeDimension.setAvailableTimes(validtimes, 'replace');
(keepPosition) ? self.timeDimension.setCurrentTimeIndex(self.timeDimension.getCurrentTimeIndex() || 0) : self.timeDimension.setCurrentTimeIndex(0);
self.timeDimension.setCurrentTimeIndex(keepTimeIndex && timeIndex > 0 && timeIndex || 0);
console.log(self.timeDimension.getCurrentTimeIndex());
if (this.timeDimension._syncedLayers.length > 0) {
self.update({
date: +moment(self.timeDimension.getCurrentTime()).utc().format("X"),
......
This diff is collapsed.
......@@ -120,9 +120,17 @@ export class Player extends L.Control {
public getTimeDimension() {
return this.timeDimension;
}
public getCurrentTimeIndex() {
return this.timeDimension.getCurrentTimeIndex();
}
public setCurrentTimeIndex(index) {
return this.timeDimension.setCurrentTimeIndex(index);
}
public refresh(keepPosition:boolean) {
public refresh(keepTimeIndex:boolean) {
var self = this;
if (self.timeDimension) {
var allAvailableTimes = [];
......@@ -137,8 +145,12 @@ 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');
var timeIndex = self.timeDimension.getCurrentTimeIndex();
console.log(self.timeDimension.getCurrentTimeIndex());
self.timeDimension.setAvailableTimes(validtimes, 'replace');
(keepPosition)?self.timeDimension.setCurrentTimeIndex(self.timeDimension.getCurrentTimeIndex() || 0):self.timeDimension.setCurrentTimeIndex(0);
self.timeDimension.setCurrentTimeIndex(keepTimeIndex && timeIndex > 0 && timeIndex|| 0);
console.log(self.timeDimension.getCurrentTimeIndex());
if (this.timeDimension._syncedLayers.length > 0) {
self.update({
date: +moment(self.timeDimension.getCurrentTime()).utc().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