Merge pull request #175 from CartoDB/named-maps

Throws error when calling setCartoCSS or setSQL with named maps
This commit is contained in:
Francisco Dans 2015-04-24 10:34:27 +02:00
commit 58345d248e
3 changed files with 6 additions and 2 deletions

View File

@ -60,7 +60,7 @@ One of two core classes for the Torque library - it is used to create an animate
| Method | options | returns | Description |
|-----------|:-----------|:----------|:---------------------------------------|
| ```setCartoCSS(cartocss)``` | ```cartocss string``` | ```this``` | style the map rendering using client-side cartocss |
| ```setCartoCSS(cartocss)``` | ```cartocss string``` | ```this``` | style the map rendering using client-side cartocss (not available with named maps) |
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
@ -89,7 +89,7 @@ This should be ```string``` encoded in Javascript.
### Data methods
| Method | options | returns | Description |
|-----------|:-----------|:----------|:---------------------------------------|
| ```setSQL(sql statement)``` | ```SQL string``` | ```this``` | Change the SQL on the data table |
| ```setSQL(sql statement)``` | ```SQL string``` | ```this``` | Change the SQL on the data table (not available with named maps) |
| ```error(callback)``` | ```callback function with a list of errors as argument``` | ```this``` | specifies a callback function to run if there are query errors |
##### SQL Example

View File

@ -122,6 +122,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
},
setSQL: function(sql) {
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
if (!this.provider || !this.provider.setSQL) {
throw new Error("this provider does not support SQL");
}
@ -266,6 +267,7 @@ GMapsTorqueLayer.prototype = torque.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");
var shader = new carto.RendererJS().render(cartocss);
this.shader = shader;
if (this.renderer) {

View File

@ -168,6 +168,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
},
setSQL: function(sql) {
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
if (!this.provider || !this.provider.setSQL) {
throw new Error("this provider does not support SQL");
}
@ -328,6 +329,7 @@ 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');
var shader = new carto.RendererJS().render(cartocss);
this.renderer.setShader(shader);