Setting cartocss in internal style

This commit is contained in:
xavijam 2016-09-22 11:51:33 +02:00
parent ddf487f56d
commit 35251805bf

View File

@ -77,7 +77,7 @@ var CartoDatasource = require('./datasource');
this.TILE_SIZE = 256; this.TILE_SIZE = 256;
this._style = null; this._style = null;
this._gradients = {}; this._gradients = {};
this._forcePoints = false; this._forcePoints = false;
} }
@ -111,6 +111,9 @@ var CartoDatasource = require('./datasource');
// //
setCartoCSS: function(cartocss, callback) { setCartoCSS: function(cartocss, callback) {
var self = this; var self = this;
this.style = cartocss;
if (PointRenderer.isTurboCarto(cartocss)) { if (PointRenderer.isTurboCarto(cartocss)) {
var datasource = new CartoDatasource(self.layer._tiles); var datasource = new CartoDatasource(self.layer._tiles);
turbocarto(cartocss, datasource, function (err, parsedCartoCSS) { turbocarto(cartocss, datasource, function (err, parsedCartoCSS) {
@ -198,7 +201,7 @@ var CartoDatasource = require('./datasource');
i.src = canvas.toDataURL(); i.src = canvas.toDataURL();
return i; return i;
} }
return canvas; return canvas;
}, },
@ -234,7 +237,7 @@ var CartoDatasource = require('./datasource');
} }
} }
} }
prof.end(true); prof.end(true);
return callback && callback(null); return callback && callback(null);
@ -278,7 +281,7 @@ var CartoDatasource = require('./datasource');
}, },
// //
// renders a tile in the canvas for key defined in // renders a tile in the canvas for key defined in
// the torque tile // the torque tile
// //
_renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars) { _renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars) {
@ -315,7 +318,7 @@ var CartoDatasource = require('./datasource');
} }
} }
} }
prof.end(true); prof.end(true);
}, },
@ -483,7 +486,7 @@ var CartoDatasource = require('./datasource');
} }
gradient = {}; gradient = {};
var colorize = this._style['image-filters'].args; var colorize = this._style['image-filters'].args;
var increment = 1/colorize.length; var increment = 1/colorize.length;
for (var i = 0; i < colorize.length; i++){ for (var i = 0; i < colorize.length; i++){
var key = increment * i + increment; var key = increment * i + increment;