Merge pull request #276 from CartoDB/issue-cartodb-10964

Don't throw an exception when a named map tries to set a new cartocss over the torque layer
This commit is contained in:
Javier Álvarez Medina 2016-12-05 15:15:56 +01:00 committed by GitHub
commit 2e1a020c3c
2 changed files with 13 additions and 2 deletions

View File

@ -321,7 +321,13 @@ GMapsTorqueLayer.prototype = torque.extend({},
* set the cartocss for the current renderer
*/
setCartoCSS: function(cartocss) {
if (this.provider && 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');
if (this.provider && this.provider.options.named_map) {
console.log('Torque layer: CartoCSS style on named maps is read-only');
return false;
}
var shader = new carto.RendererJS().render(cartocss);
this.shader = shader;
if (this.renderer) {

View File

@ -391,8 +391,13 @@ L.TorqueLayer = L.CanvasLayer.extend({
* set the cartocss for the current renderer
*/
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');
if (this.provider && this.provider.options.named_map) {
console.log('Torque layer: CartoCSS style on named maps is read-only');
return false;
}
this.renderer.setCartoCSS(cartocss, function () {
// provider options
var options = torque.common.TorqueLayer.optionsFromLayer(this.renderer._shader.findLayer({ name: 'Map' }));