added setTime

This commit is contained in:
javi 2013-08-29 12:52:40 +02:00
parent 974d62829f
commit 7550236682

View File

@ -19,6 +19,9 @@ L.TorqueLayer = L.CanvasLayer.extend({
options.tileLoader = true;
this.key = 0;
options.resolution = options.resolution || 2;
options.steps = options.steps || 100;
this.animator = new torque.Animator(function(time) {
var k = time | 0;
if(self.key !== k) {
@ -89,13 +92,26 @@ L.TorqueLayer = L.CanvasLayer.extend({
this.redraw();
},
/**
* helper function, does the same than ``setKey`` but only
* accepts scalars.
*/
setTime: function(time) {
if(time === undefined || time.length !== undefined) {
throw new Error("setTime only accept scalars");
}
this.setKey(time);
},
/**
* set the cartocss for the current renderer
*/
setCartoCSS: function(cartocss) {
if (!this.renderer) throw new Error('renderer is not valid');
return this.renderer.setCartoCSS(cartocss);
this.renderer.setCartoCSS(cartocss);
this.redraw();
return this;
}
});