From 6423f5f9cf2e9980051d69d064d5df78014cc57a Mon Sep 17 00:00:00 2001 From: javi Date: Thu, 29 Aug 2013 13:06:56 +0200 Subject: [PATCH] set cartocss on the startup --- lib/torque/gmaps/torque.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/torque/gmaps/torque.js b/lib/torque/gmaps/torque.js index 927d402..983039e 100644 --- a/lib/torque/gmaps/torque.js +++ b/lib/torque/gmaps/torque.js @@ -3,6 +3,7 @@ function GMapsTorqueLayer(options) { var self = this; this.key = 0; + this.cartocss = null; this.options = _.extend({}, options); _.defaults(this.options, { provider: 'sql_api', @@ -62,6 +63,10 @@ GMapsTorqueLayer.prototype = _.extend({}, this._initTileLoader(this.options.map, this.getProjection()); + if (this.cartocss) { + this.renderer.setCartoCSS(this.cartocss); + } + }, getCanvas: function() { @@ -134,9 +139,11 @@ GMapsTorqueLayer.prototype = _.extend({}, * set the cartocss for the current renderer */ setCartoCSS: function(cartocss) { - if (!this.renderer) throw new Error('renderer is not valid'); + if (!this.renderer) { + this.cartocss = cartocss; + return this; + } this.renderer.setCartoCSS(cartocss); - this.redraw(); return this; },