reduces repetition, adds callback
This commit is contained in:
parent
4cd282a6d4
commit
bfc2489b5c
@ -392,25 +392,25 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
setCartoCSS: function(cartocss) {
|
||||
if (this.provider.options.named_map) throw new Error("CartoCSS style on named maps is read-only");
|
||||
if (!this.renderer) throw new Error('renderer is not valid');
|
||||
var shader = new carto.RendererJS().render(cartocss);
|
||||
this.renderer.setShader(shader);
|
||||
this.renderer.setCartoCSS(cartocss, function () {
|
||||
// provider options
|
||||
var options = torque.common.TorqueLayer.optionsFromLayer(this.renderer._shader.findLayer({ name: 'Map' }));
|
||||
this.provider.setCartoCSS && this.provider.setCartoCSS(cartocss);
|
||||
if(this.provider.setOptions(options)) {
|
||||
this._reloadTiles();
|
||||
}
|
||||
|
||||
// provider options
|
||||
var options = torque.common.TorqueLayer.optionsFromLayer(shader.findLayer({ name: 'Map' }));
|
||||
this.provider.setCartoCSS && this.provider.setCartoCSS(cartocss);
|
||||
if(this.provider.setOptions(options)) {
|
||||
this._reloadTiles();
|
||||
}
|
||||
torque.extend(this.options, options);
|
||||
|
||||
torque.extend(this.options, options);
|
||||
// animator options
|
||||
if (options.animationDuration) {
|
||||
this.animator.duration(options.animationDuration);
|
||||
}
|
||||
this._clearCaches();
|
||||
this.redraw();
|
||||
return this;
|
||||
}.bind(this));
|
||||
|
||||
// animator options
|
||||
if (options.animationDuration) {
|
||||
this.animator.duration(options.animationDuration);
|
||||
}
|
||||
this._clearCaches();
|
||||
this.redraw();
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -109,17 +109,19 @@ var CartoDatasource = require('./datasource');
|
||||
//
|
||||
// sets the cartocss style to render stuff
|
||||
//
|
||||
setCartoCSS: function(cartocss) {
|
||||
setCartoCSS: function(cartocss, callback) {
|
||||
var self = this;
|
||||
if (PointRenderer.isTurboCarto(cartocss)) {
|
||||
var datasource = new CartoDatasource(self.layer._tiles);
|
||||
turbocarto(cartocss, datasource, function (err, parsedCartoCSS) {
|
||||
self.setShader(new carto.RendererJS().render(parsedCartoCSS));
|
||||
self.layer.redraw();
|
||||
self.layer.animator.start()
|
||||
self.layer.animator.start();
|
||||
callback && callback();
|
||||
});
|
||||
} else {
|
||||
self.setShader(new carto.RendererJS().render(cartocss));
|
||||
callback && callback();
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user