Merge pull request #128 from CartoDB/timetostep
Adds timeToStep() method
This commit is contained in:
commit
db41e24b42
@ -240,6 +240,14 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
||||
return new Date(time);
|
||||
},
|
||||
|
||||
timeToStep: function(timestamp) {
|
||||
if (typeof timestamp === "Date") timestamp = timestamp.getTime();
|
||||
if (!this.provider) return 0;
|
||||
var times = this.provider.getKeySpan();
|
||||
var step = (this.provider.getSteps() * (timestamp - times.start)) / (times.end - times.start);
|
||||
return step;
|
||||
},
|
||||
|
||||
getStep: function() {
|
||||
return this.key;
|
||||
},
|
||||
|
@ -295,6 +295,14 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
var time = times.start + (times.end - times.start)*(step/this.provider.getSteps());
|
||||
return new Date(time);
|
||||
},
|
||||
|
||||
timeToStep: function(timestamp) {
|
||||
if (typeof timestamp === "Date") timestamp = timestamp.getTime();
|
||||
if (!this.provider) return 0;
|
||||
var times = this.provider.getKeySpan();
|
||||
var step = (this.provider.getSteps() * (timestamp - times.start)) / (times.end - times.start);
|
||||
return step;
|
||||
},
|
||||
|
||||
getStep: function() {
|
||||
return this.key;
|
||||
|
Loading…
Reference in New Issue
Block a user