- CartodbLayers ⇐
Stream Main class to expose all the module of this library
- Memoizable
Abstract Class to implement memoized methods
- Rest
Class to communicate with CARTO Rest API
- Turbocarto
Class to manipulate TurboCARTO strings.
Main class to expose all the module of this library
Kind: global class
Extends: Stream
Properties
| Name | Type | Description |
|---|---|---|
| client | CartoDB.SQL |
CartoDB SQL client |
| rest | Rest |
Rest client |
| turbocarto | Turbocarto |
TruboCARTO client |
| Param | Type | Default | Description |
|---|---|---|---|
| [args.user] | String |
cartodb |
CARTO username |
| args.api_key | String |
CARTO api key |
Abstract Class to implement memoized methods
Kind: global abstract class
Properties
| Name | Type | Description |
|---|---|---|
| methods | Object |
All the methods of the class |
| memoized | Object |
All the methods of the class, but memoized (no expiration) |
- Memoizable
- new Memoizable()
- .throttled([wait]) ⇒
Object
This abstract class should not call this constructor method or an error will be thrown.
Throws:
ErrorThrown when the class is called directly.
Returns the methods of the class, wrapped inside a throttled function
Kind: instance method of Memoizable
Returns: Object - All the methods of the class
| Param | Type | Default | Description |
|---|---|---|---|
| [wait] | Number |
|
Throttle duration in millisecond. The null means no limitations. |
Class to communicate with CARTO Rest API
Kind: global class
- Rest
- new Rest(args)
- instance
- .get(args) ⇒
Promise - .post(args) ⇒
Promise - .delete(args) ⇒
Promise .del(args) ⇒Promise- .findInfowindow(viz) ⇒
Object - .buildParams([page], [per_page]) ⇒
Object .buildQuery(page, per_page) ⇒Object.layers() ⇒Array- .getLayers() ⇒
Array - .tables() ⇒
Array - .emitterAsPromise(emitter) ⇒
Promise - .createNamedMap(template) ⇒
Promise - .deleteNamedMap(template_id) ⇒
Promise - .deleteNamedMapIfExist(template_id) ⇒
Promise .instanciate(template_id, params) ⇒Promise- .instantiateNamedMap(template_id, params) ⇒
Promise .viz(id, [resolveNamedMap]) ⇒Promise- .getVizV2(id, [resolveNamedMap]) ⇒
Promise - .getVizV1(id) ⇒
Promise - .named(name) ⇒
Promise - .getNamedMap(name) ⇒
Promise - .getNamedMaps() ⇒
Promise - .importedAt() ⇒
String - .uniqueNamedMapId(id, [prefix]) ⇒
String - .projection(id, name, cartocss, sql, interactivity) ⇒
Promise - .vizNewNamedMap(id, name, cartocss, sql, interactivity) ⇒
Promise - .basemapLayer() ⇒
Object - .static(id, noBasemap) ⇒
Object - .search(q, [type], page, per_page)
- .image(specs, [width], [height], [protocol], [format], [useCenter]) ⇒
String - .data(id) ⇒
Promise - .vizSqlQuery(id) ⇒
Promise - .vizRelatedTables(id) ⇒
Promise - .vizTable(id) ⇒
String - .fillParams(sql) ⇒
String - .fields(id) ⇒
Array
- .get(args) ⇒
- static
- .firstNonNul(tasks) ⇒
Mixed - .queryCollection(data, path, force) ⇒
Mixed - .sqlQueryToTable(sql) ⇒
String
- .firstNonNul(tasks) ⇒
Create a Rest instance
| Param | Type | Default | Description |
|---|---|---|---|
| args | Object |
An object to configure the client with a "user" and "api_key" properties. | |
| [args.user] | String |
cartodb |
CARTO username |
| args.api_key | String |
CARTO api key |
Perform a GET request over CARTO API.
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| args | Object |
Spread parameters to axios method |
Perform a POST request over CARTO API.
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| args | Object |
Spread parameters to axios method |
Perform a DELETE request over CARTO API.
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| args | Object |
Spread parameters to axios method |
Deprecated
Perform a DELETE request over CARTO API.
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| args | Object |
Spread parameters to axios method |
Find an infowindow description object in the given vizualisation
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| viz | Object |
Vizualisation description object from CARTO API |
Build query parameters to paginate results from CARTO
Kind: instance method of Rest
| Param | Type | Default |
|---|---|---|
| [page] | Number |
1 |
| [per_page] | Number |
10 |
Deprecated
Build query parameters to paginate results from CARTO
Kind: instance method of Rest
| Param | Type |
|---|---|
| page | Number |
| per_page | Number |
Deprecated
Get all "layers" which is basicaly all user's vizualisations
Kind: instance method of Rest
Get all "layers" which is basicaly all user's vizualisations
Kind: instance method of Rest
Get all user's tables
Kind: instance method of Rest
Cast the given event emmiter to a Promise
Kind: instance method of Rest
| Param | Type |
|---|---|
| emitter | Object |
Create a named map based on the given template object
Kind: instance method of Rest
| Param | Type |
|---|---|
| template | Object |
Delete a named map
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| template_id | String |
Id of the template to delete |
Delete a named map but return null without throwing an error if the named map doesn't exist
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| template_id | String |
Id of the template to delete |
Deprecated
Create an instance of the given name map with custom params
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| template_id | String |
Id of the template |
| params | Object |
Params of the named map |
Create an instance of the given name map with custom params
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| template_id | String |
Id of the template |
| params | Object |
Params of the named map |
Deprecated
Get a vizualisation using CARTO API v2
Kind: instance method of Rest
| Param | Type | Default | Description |
|---|---|---|---|
| id | String |
Id of the vizualisation | |
| [resolveNamedMap] | Boolean |
true |
Should add the vizualisation's named map |
Get a vizualisation using CARTO API v2
Kind: instance method of Rest
| Param | Type | Default | Description |
|---|---|---|---|
| id | String |
Id of the vizualisation | |
| [resolveNamedMap] | Boolean |
true |
Should add the vizualisation's named map |
Get a vizualisation using CARTO API v1
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| id | String |
Id of the vizualisation |
Get a named map using CARTO API v1
Kind: instance method of Rest
Depracted:
| Param | Type | Description |
|---|---|---|
| name | String |
Name of the Named Map |
Get a named map using CARTO API v1
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| name | String |
Name of the Named Map |
Get all named maps using CARTO API v1
Kind: instance method of Rest
Get the current date as a locale string in UTC timezone
Kind: instance method of Rest
Get a unique named map id based on the date
Kind: instance method of Rest
| Param | Type | Default | Description |
|---|---|---|---|
| id | String |
Named Map name (or id) | |
| [prefix] | String |
"dtpl" |
Prefix to all namedMap ids |
Instanciate a new Named Map with a custom CartoCSS and SQL projection
Kind: instance method of Rest
Depracted:
| Param | Type | Description |
|---|---|---|
| id | String |
Named Map name (or id) |
| name | String |
Name of the new named map |
| cartocss | String |
Custom CartoCSS |
| sql | String |
Custom SQL |
| interactivity | String |
A commat separated list of fields the user can interact with |
Instanciate a new Named Map with a custom CartoCSS and SQL projection
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| id | String |
Named Map name (or id) |
| name | String |
Name of the new named map |
| cartocss | String |
Custom CartoCSS |
| sql | String |
Custom SQL |
| interactivity | String |
A commat separated list of fields the user can interact with |
Get the default basemap layer definition
Kind: instance method of Rest
Get the static definition (image) of a given vizualisation
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| id | String |
Vizualisation id |
| noBasemap | Boolean |
Disabled the basemap layer in the static visualization |
Search a visualization by its name
Kind: instance method of Rest
| Param | Default | Description |
|---|---|---|
| q | Query string | |
| [type] | derived |
Type of vizualisation to look for |
| page | Page number | |
| per_page | Number of visualizations by page |
Convert the given static definition into an image URL
Kind: instance method of Rest
Returns: String - Image URL
| Param | Default | Description |
|---|---|---|
| specs | Static definition | |
| [width] | 300 |
Image width |
| [height] | 170 |
Image height |
| [protocol] | https |
URL protocol |
| [format] | png |
Image format |
| [useCenter] | false |
The given definition uses center instead of boundaries to pane the map. |
Get data for a given vizualisation using API v2
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| id | String |
Id of the vizualisation |
Get SQL query of a given vizualisation
Kind: instance method of Rest
Returns: Promise - SQL query as string
| Param | Type | Description |
|---|---|---|
| id | String |
Id of the vizualisation |
Get related table of a given vizualisation using API v1
Kind: instance method of Rest
Returns: Promise - A list of related tables
| Param | Type | Description |
|---|---|---|
| id | String |
Id of the vizualisation |
Get the name of table used by a given vizualisation
Kind: instance method of Rest
Returns: String - Table name
| Param | Type | Description |
|---|---|---|
| id | String |
Id of the vizualisation |
Fills default parameters for a given SQL query template
Kind: instance method of Rest
Returns: String - SQL query
| Param | Type | Description |
|---|---|---|
| sql | String |
SQL query template |
Get fields (table rows) for a given vizualization using API v2
Kind: instance method of Rest
| Param | Type | Description |
|---|---|---|
| id | String |
Id of the vizualisation |
Evaluate the given list of promises in series, then stops and return the first non null value.
Kind: static method of Rest
Returns: Mixed - First non null value
| Param | Type | Description |
|---|---|---|
| tasks | Array |
List of promises |
Return the value of the given path in the data object
Kind: static method of Rest
| Param | Type | Description |
|---|---|---|
| data | Object |
Object to look into |
| path | String |
Path to use |
| force | Mixed |
Specify an object to be returned from the query if the query fails. |
Get the table from a given SQL query
Kind: static method of Rest
Returns: String - Table name from the query (or null if any)
| Param | Type | Description |
|---|---|---|
| sql | String |
SQL query |
Class to manipulate TurboCARTO strings.
Kind: global class
Create a Turbocarto instance
| Param | Type | Description |
|---|---|---|
| rest | Rest |
An instance of Rest |
Populate the TurboCARTO strings with data from an SQL query in order to generate CartoCSS.
Kind: instance method of Turbocarto
| Param | Type | Description |
|---|---|---|
| turbocarto | string |
TurboCARTO string. |
| sql | string |
SQL query to read data. |