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; options.tileLoader = true;
this.key = 0; this.key = 0;
options.resolution = options.resolution || 2;
options.steps = options.steps || 100;
this.animator = new torque.Animator(function(time) { this.animator = new torque.Animator(function(time) {
var k = time | 0; var k = time | 0;
if(self.key !== k) { if(self.key !== k) {
@ -89,13 +92,26 @@ L.TorqueLayer = L.CanvasLayer.extend({
this.redraw(); 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 * set the cartocss for the current renderer
*/ */
setCartoCSS: function(cartocss) { setCartoCSS: function(cartocss) {
if (!this.renderer) throw new Error('renderer is not valid'); if (!this.renderer) throw new Error('renderer is not valid');
return this.renderer.setCartoCSS(cartocss); this.renderer.setCartoCSS(cartocss);
this.redraw();
return this;
} }
}); });