Skip to content

Commit 58345d2

Browse files
committed
Merge pull request #175 from CartoDB/named-maps
Throws error when calling setCartoCSS or setSQL with named maps
2 parents d7a2840 + e98c518 commit 58345d2

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

doc/API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ One of two core classes for the Torque library - it is used to create an animate
6060

6161
| Method | options | returns | Description |
6262
|-----------|:-----------|:----------|:---------------------------------------|
63-
| ```setCartoCSS(cartocss)``` | ```cartocss string``` | ```this``` | style the map rendering using client-side cartocss |
63+
| ```setCartoCSS(cartocss)``` | ```cartocss string``` | ```this``` | style the map rendering using client-side cartocss (not available with named maps) |
6464

6565
The full CartoCSS spec is not supported by Torque but instead only a limited subset with some additions related to torque rendering. To see the full list of supported parameters, read the [Torque CartoCSS documentation](CartoCSS.md). ``value`` and ``zoom`` variables can be used. ``value`` is the value of aggregation (see ``countby`` constructor option). ``zoom`` is the current zoom being rendered
6666

@@ -89,7 +89,7 @@ This should be ```string``` encoded in Javascript.
8989
### Data methods
9090
| Method | options | returns | Description |
9191
|-----------|:-----------|:----------|:---------------------------------------|
92-
| ```setSQL(sql statement)``` | ```SQL string``` | ```this``` | Change the SQL on the data table |
92+
| ```setSQL(sql statement)``` | ```SQL string``` | ```this``` | Change the SQL on the data table (not available with named maps) |
9393
| ```error(callback)``` | ```callback function with a list of errors as argument``` | ```this``` | specifies a callback function to run if there are query errors |
9494

9595
##### SQL Example

lib/torque/gmaps/torque.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
122122
},
123123

124124
setSQL: function(sql) {
125+
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
125126
if (!this.provider || !this.provider.setSQL) {
126127
throw new Error("this provider does not support SQL");
127128
}
@@ -266,6 +267,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
266267
* set the cartocss for the current renderer
267268
*/
268269
setCartoCSS: function(cartocss) {
270+
if (this.provider.options.named_map) throw new Error("CartoCSS style on named maps is read-only");
269271
var shader = new carto.RendererJS().render(cartocss);
270272
this.shader = shader;
271273
if (this.renderer) {

lib/torque/leaflet/torque.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
168168
},
169169

170170
setSQL: function(sql) {
171+
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
171172
if (!this.provider || !this.provider.setSQL) {
172173
throw new Error("this provider does not support SQL");
173174
}
@@ -328,6 +329,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
328329
* set the cartocss for the current renderer
329330
*/
330331
setCartoCSS: function(cartocss) {
332+
if (this.provider.options.named_map) throw new Error("CartoCSS style on named maps is read-only");
331333
if (!this.renderer) throw new Error('renderer is not valid');
332334
var shader = new carto.RendererJS().render(cartocss);
333335
this.renderer.setShader(shader);

0 commit comments

Comments
 (0)