Don't throw an exception when a named map tries to set a new cartocss

This commit is contained in:
xavijam 2016-12-05 13:31:59 +01:00
parent 65a115e9b1
commit 62fc84b9be
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.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' }));