Merge remote-tracking branch 'origin/master' into health-check
Conflicts: NEWS.md npm-shrinkwrap.json package.json
This commit is contained in:
commit
07fd7619bc
20
NEWS.md
20
NEWS.md
@ -1,12 +1,26 @@
|
||||
1.22.0 -- 2014-mm-dd
|
||||
--------------------
|
||||
|
||||
Announcements:
|
||||
- Upgrades windshaft to 0.32.0
|
||||
|
||||
New features:
|
||||
- Health check endpoint
|
||||
|
||||
1.21.2 -- 2014-12-15
|
||||
--------------------
|
||||
|
||||
Announcements:
|
||||
- Upgrades windshaft to 0.32.4
|
||||
|
||||
|
||||
1.21.1 -- 2014-12-11
|
||||
--------------------
|
||||
|
||||
Announcements:
|
||||
- Upgrades windshaft to 0.32.2
|
||||
|
||||
Bugfixes:
|
||||
- Closes fd for log files on `kill -HUP` (#230)
|
||||
|
||||
|
||||
|
||||
1.21.0 -- 2014-10-24
|
||||
--------------------
|
||||
|
5
app.js
5
app.js
@ -116,9 +116,12 @@ process.on('SIGUSR2', function() {
|
||||
});
|
||||
|
||||
process.on('SIGHUP', function() {
|
||||
log4js.configure(log4js_config);
|
||||
global.log4js.clearAndShutdownAppenders(function() {
|
||||
global.log4js.configure(log4js_config);
|
||||
global.logger = log4js.getLogger();
|
||||
console.log('Log files reloaded');
|
||||
});
|
||||
});
|
||||
|
||||
process.on('uncaughtException', function(err) {
|
||||
logger.error('Uncaught exception: ' + err.stack);
|
||||
|
@ -40,7 +40,7 @@ var config = {
|
||||
// If log_filename is given logs will be written
|
||||
// there, in append mode. Otherwise stdout is used (default).
|
||||
// Log file will be re-opened on receiving the HUP signal
|
||||
,log_filename: 'logs/node-windshaft.log'
|
||||
,log_filename: undefined
|
||||
// Templated database username for authorized user
|
||||
// Supported labels: 'user_id' (read from redis)
|
||||
,postgres_auth_user: 'development_cartodb_user_<%= user_id %>'
|
||||
@ -63,6 +63,7 @@ var config = {
|
||||
*/
|
||||
row_limit: 65535,
|
||||
simplify_geometries: true,
|
||||
use_overviews: true, // use overviews to retrieve raster
|
||||
/*
|
||||
* Set persist_connection to false if you want
|
||||
* database connections to be closed on renderer
|
||||
|
@ -65,6 +65,7 @@ var config = {
|
||||
*/
|
||||
persist_connection: false,
|
||||
simplify_geometries: true,
|
||||
use_overviews: true, // use overviews to retrieve raster
|
||||
max_size: 500
|
||||
}
|
||||
,mapnik_version: undefined
|
||||
|
@ -57,6 +57,7 @@ var config = {
|
||||
extent: "-20037508.3,-20037508.3,20037508.3,20037508.3",
|
||||
row_limit: 65535,
|
||||
simplify_geometries: true,
|
||||
use_overviews: true, // use overviews to retrieve raster
|
||||
/*
|
||||
* Set persist_connection to false if you want
|
||||
* database connections to be closed on renderer
|
||||
|
@ -57,6 +57,7 @@ var config = {
|
||||
extent: "-20037508.3,-20037508.3,20037508.3,20037508.3",
|
||||
row_limit: 65535,
|
||||
simplify_geometries: true,
|
||||
use_overviews: true, // use overviews to retrieve raster
|
||||
/*
|
||||
* Set persist_connection to false if you want
|
||||
* database connections to be closed on renderer
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Kind of maps
|
||||
|
||||
Windshaft-CartoDB supports these kind of maps:
|
||||
Windshaft-CartoDB supports the following types of maps:
|
||||
|
||||
- [Temporary maps](#temporary-maps) (created by anyone)
|
||||
- [Detached maps](#detached-maps)
|
||||
@ -12,14 +12,14 @@ Windshaft-CartoDB supports these kind of maps:
|
||||
## Temporary maps
|
||||
|
||||
Temporary maps have no owners and are anonymous in nature.
|
||||
There are two kind of temporary maps:
|
||||
There are two kinds of temporary maps:
|
||||
|
||||
- Detached maps (aka MultiLayer-API)
|
||||
- Inline maps
|
||||
|
||||
### Detached maps
|
||||
|
||||
Detached maps are maps which are configured with a request
|
||||
Detached maps are maps that are configured with a request
|
||||
obtaining a temporary token and then used by referencing
|
||||
the obtained token. The token expires automatically when unused.
|
||||
|
||||
|
253
docs/Map-API.md
253
docs/Map-API.md
@ -1,6 +1,6 @@
|
||||
## Maps API
|
||||
|
||||
The CartoDB Maps API allows you to generate maps based on data hosted in your CartoDB account and style them using CartoCSS. The API generates a XYZ based URL to fetch Web Mercator projected tiles using web clients like Leaflet, Google Maps, OpenLayers.
|
||||
The CartoDB Maps API allows you to generate maps based on data hosted in your CartoDB account, and you can apply custom SQL and CartoCSS to the data. The API generates a XYZ-based URL to fetch Web Mercator projected tiles using web clients such as [Leaflet](http://leafletjs.com), [Google Maps](https://developers.google.com/maps/), or [OpenLayers](http://openlayers.org/).
|
||||
|
||||
You can create two types of maps with the Maps API:
|
||||
|
||||
@ -8,7 +8,7 @@ You can create two types of maps with the Maps API:
|
||||
Maps that can be created using your CartoDB public data. Any client can change the read-only SQL and CartoCSS parameters that generate the map tiles. These maps can be created from a JavaScript application alone and no authenticated calls are needed. See [this CartoDB.js example]({{ '/cartodb-platform/cartodb-js.html' | prepend: site.baseurl }}).
|
||||
|
||||
- **Named maps**
|
||||
Maps that access to your private data. These maps require an owner to setup and modify any SQL and CartoCSS parameters and are not modifiable without new setup calls.
|
||||
Maps that have access to your private data. These maps require an owner to setup and modify any SQL and CartoCSS parameters and are not modifiable without new setup calls.
|
||||
|
||||
## Quickstart
|
||||
|
||||
@ -16,7 +16,7 @@ You can create two types of maps with the Maps API:
|
||||
|
||||
Here is an example of how to create an anonymous map with JavaScript:
|
||||
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
var mapconfig = {
|
||||
"version": "1.0.1",
|
||||
"layers": [{
|
||||
@ -37,19 +37,18 @@ $.ajax({
|
||||
url: 'http://documentation.cartodb.com/api/v1/map',
|
||||
data: JSON.stringify(mapconfig),
|
||||
success: function(data) {
|
||||
var templateUrl = 'http://documentation.cartodb.com/api/v1/map/' + data.layergroupid + '{z}/{x}/{y}.png'
|
||||
var templateUrl = 'http://documentation.cartodb.com/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png'
|
||||
console.log(templateUrl);
|
||||
}
|
||||
})
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
### Named maps
|
||||
|
||||
Let's create a named map using some private tables in a CartoDB account.
|
||||
The following API call creates a map of European countries that have a white fill color:
|
||||
The following map config sets up a map of European countries that have a white fill color:
|
||||
|
||||
{% highlight javascript %}
|
||||
// mapconfig.json
|
||||
```javascript
|
||||
{
|
||||
"version": "0.0.1",
|
||||
"name": "test",
|
||||
@ -67,38 +66,38 @@ The following API call creates a map of European countries that have a white fil
|
||||
}]
|
||||
}
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
The map config needs to be sent to CartoDB's Map API using an authenticated call. Here we use a command line tool called `curl`. For more info about this tool see [this blog post](http://quickleft.com/blog/command-line-tutorials-curl) or type ``man curl`` in bash. Using `curl` the call would look like:
|
||||
The map config needs to be sent to CartoDB's Map API using an authenticated call. Here we will use a command line tool called `curl`. For more info about this tool, see [this blog post](http://quickleft.com/blog/command-line-tutorials-curl), or type ``man curl`` in bash. Using `curl`, and storing the config from above in a file `mapconfig.json`, the call would look like:
|
||||
|
||||
<div class="code-title notitle code-request"></div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
curl 'https://{account}.cartodb.com/api/v1/map/named?api_key=APIKEY' -H 'Content-Type: application/json' -d @mapconfig.json
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
To get the `URL` to fetch the tiles you need to instantiate the map.
|
||||
To get the `URL` to fetch the tiles you need to instantiate the map, where `template_id` is the template name from the previous response.
|
||||
|
||||
<div class="code-title notitle code-request"></div>
|
||||
{% highlight bash %}
|
||||
curl 'http://{account}.cartodb.com/api/v1/map/named/test' -H 'Content-Type: application/json'
|
||||
{% endhighlight %}
|
||||
```bash
|
||||
curl -X POST 'http://{account}.cartodb.com/api/v1/map/named/:template_id' -H 'Content-Type: application/json'
|
||||
```
|
||||
|
||||
The response will return JSON with properties for the `layergroupid` and the timestamp (`last_updated`) of the last data modification.
|
||||
|
||||
Here is an example response:
|
||||
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"layergroupid": "c01a54877c62831bb51720263f91fb33:0",
|
||||
"last_updated": "1970-01-01T00:00:00.000Z"
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
You can use the `layergroupid` to instantiate a URL template for accessing tiles on the client. Here we use the `layergroupid` from the example response above in this URL template:
|
||||
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
http://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/{z}/{x}/{y}.png
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
## General Concepts
|
||||
|
||||
@ -106,7 +105,7 @@ The following concepts are the same for every endpoint in the API except when it
|
||||
|
||||
### Auth
|
||||
|
||||
By default, users do not have access to private tables in CartoDB. In order to instantiate a map from private table data an API Key is required. Additionally, to include some endpoints an API Key must be included (e.g. creating a named map).
|
||||
By default, users do not have access to private tables in CartoDB. In order to instantiate a map from private table data, an API Key is required. Additionally, to include some endpoints, an API Key must be included (e.g. creating a named map).
|
||||
|
||||
To execute an authorized request, api_key=YOURAPIKEY should be added to the request URL. The param can be also passed as POST param. We **strongly advise** using HTTPS when you are performing requests that include your `api_key`.
|
||||
|
||||
@ -114,13 +113,13 @@ To execute an authorized request, api_key=YOURAPIKEY should be added to the requ
|
||||
|
||||
Errors are reported using standard HTTP codes and extended information encoded in JSON with this format:
|
||||
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"errors": [
|
||||
"access forbidden to table TABLE"
|
||||
]
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
If you use JSONP, the 200 HTTP code is always returned so the JavaScript client can receive errors from the JSON object.
|
||||
|
||||
@ -137,13 +136,13 @@ Anonymous maps allows you to instantiate a map given SQL and CartoCSS. It also a
|
||||
#### Definition
|
||||
|
||||
<div class="code-title notitle code-request"></div>
|
||||
{% highlight html %}
|
||||
```html
|
||||
POST /api/v1/map
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Params
|
||||
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"version": "1.0.1",
|
||||
"layers": [{
|
||||
@ -156,7 +155,7 @@ POST /api/v1/map
|
||||
}
|
||||
}]
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
Should be a [Mapconfig](https://github.com/CartoDB/Windshaft/blob/0.19.1/doc/MapConfig-1.1.0.md).
|
||||
|
||||
@ -167,9 +166,9 @@ The response includes:
|
||||
- **layergroupid**
|
||||
The ID for that map, used to compose the URL for the tiles. The final URL is:
|
||||
|
||||
{% highlight html %}
|
||||
```html
|
||||
http://{account}.cartodb.com/api/v1/map/:layergroupid/{z}/{x}/{y}.png
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
- **updated_at**
|
||||
The ISO date of the last time the data involved in the query was updated.
|
||||
@ -183,12 +182,12 @@ The response includes:
|
||||
#### Example
|
||||
|
||||
<div class="code-title code-request with-result">REQUEST</div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
curl 'http://documentation.cartodb.com/api/v1/map' -H 'Content-Type: application/json' -d @mapconfig.json
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
<div class="code-title">RESPONSE</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"layergroupid":"c01a54877c62831bb51720263f91fb33:0",
|
||||
"last_updated":"1970-01-01T00:00:00.000Z"
|
||||
@ -197,31 +196,31 @@ curl 'http://documentation.cartodb.com/api/v1/map' -H 'Content-Type: application
|
||||
"https": "https://cdb.com"
|
||||
}
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
The tiles can be accessed using:
|
||||
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
http://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/{z}/{x}/{y}.png
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
For UTF grid tiles:
|
||||
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
http://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/:layer/{z}/{x}/{y}.grid.json
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
For attributes defined in `attributes` section:
|
||||
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
http://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/:layer/attributes/:feature_id
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
Which returns JSON with the attributes defined, like:
|
||||
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{ c: 1, d: 2 }
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
Notice UTF Grid and attributes endpoints need an intenger parameter, ``layer``. That number is the 0-based index of the layer inside the mapconfig. So in this case 0 returns the UTF grid tiles/attributes for layer 0, the only layer in the example mapconfig. If a second layer was available it could be returned with 1, a third layer with 2, etc.
|
||||
|
||||
@ -232,9 +231,9 @@ The JSONP endpoint is provided in order to allow web browsers access which don't
|
||||
#### Definition
|
||||
|
||||
<div class="code-title notitle code-request"></div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
GET /api/v1/map?callback=method
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Params
|
||||
|
||||
@ -253,23 +252,24 @@ GET /api/v1/map?callback=method
|
||||
#### Example
|
||||
|
||||
<div class="code-title code-request with-result">REQUEST</div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
curl http://...
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
<div class="code-title">RESPONSE</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
### Remove
|
||||
|
||||
Anonymous maps cannot be removed by an API call. They will expire after about five minutes but sometimes longer. If an anonymous map expires and tiles are requested from it, an error will be raised. This could happen if a user leaves a map open and after time returns to the map an attempts to interact with it in a way that requires new tiles (e.g. zoom). The client will need to go through the steps of creating the map again to fix the problem.
|
||||
|
||||
|
||||
## Named Maps
|
||||
|
||||
Named maps are essentially the same as anonymous maps but the mapconfig is stored in the server and given a unique name. Two other big differences are that you can created named maps from private data and that users without an API Key can see them even though they are from that private data.
|
||||
Named maps are essentially the same as anonymous maps except the mapconfig is stored on the server and the map is given a unique name. Two other big differences are that you can create named maps from private data, and that users without an API Key can see them even though they are from that private data.
|
||||
|
||||
The main two differences compared to anonymous maps are:
|
||||
|
||||
@ -277,7 +277,7 @@ The main two differences compared to anonymous maps are:
|
||||
This allows you to control who is able to see the map based on a token auth
|
||||
|
||||
- **templates**
|
||||
Since the mapconfig is static it can contain some variables so the client con modify the map appearance using those variables.
|
||||
Since the mapconfig is static it can contain some variables so the client can modify the map's appearance using those variables
|
||||
|
||||
Template maps are persistent with no preset expiration. They can only be created or deleted by a CartoDB user with a valid API_KEY (see auth section).
|
||||
|
||||
@ -286,14 +286,16 @@ Template maps are persistent with no preset expiration. They can only be created
|
||||
#### Definition
|
||||
|
||||
<div class="code-title notitle code-request"></div>
|
||||
{% highlight html %}
|
||||
```html
|
||||
POST /api/v1/map/named
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Params
|
||||
|
||||
- **api_key** is required
|
||||
|
||||
<div class="code-title">template.json</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"version": "0.0.1",
|
||||
"name": "template_name",
|
||||
@ -328,27 +330,28 @@ POST /api/v1/map/named
|
||||
]
|
||||
}
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
##### Arguments
|
||||
|
||||
- **name**: there can be at most 1 template with the same name for any user valid names start with a letter and only contains letter, numbers or underscores
|
||||
- **name**: There can be at most _one_ template with the same name for any user. Valid names start with a letter, and only contain letters, numbers, or underscores (_).
|
||||
- **auth**:
|
||||
- **method** `"token"` or `"open"` (the default if no `"method"` is given)
|
||||
- **method** `"token"` or `"open"` (the default if no `"method"` is given).
|
||||
- **valid_tokens** when `"method"` is set to `"token"`, the values listed here allow you to instantiate the named map.
|
||||
- **placeholders**: Variables not listed here are not substituted. Variable not provided at instantiation time trigger an error. A default is required for optional variables. Type specification is used for quoting, to avoid injections see template format section below.
|
||||
- **layergroup**: the layer list definition. This is the MapConfig explained in anonymous maps see https://github.com/CartoDB/Windshaft/blob/master/doc/MapConfig-1.1.0.md
|
||||
- **layergroup**: the layer list definition. This is the MapConfig explained in anonymous maps. See [MapConfig documentation](https://github.com/CartoDB/Windshaft/blob/master/doc/MapConfig-1.1.0.md) for more info.
|
||||
|
||||
#### Template Format
|
||||
|
||||
A templated `layergroup` allows using placeholders in the "cartocss" and "sql" elements of the "option" object in any "layer" of a layergroup configuration
|
||||
A templated `layergroup` allows the use of placeholders in the "cartocss" and "sql" elements of the "option" object in any "layer" of a `layergroup` configuration
|
||||
|
||||
Valid placeholder names start with a letter and can only contain letters, numbers or underscores. They have to be written between `<%=` and `%>` strings in order to be replaced.
|
||||
Valid placeholder names start with a letter and can only contain letters, numbers, or underscores. They have to be written between the `<%=` and `%>` strings in order to be replaced.
|
||||
|
||||
##### Example
|
||||
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
<%= my_color %>
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
The set of supported placeholders for a template will need to be explicitly defined with a specific type and default value for each.
|
||||
|
||||
@ -366,19 +369,19 @@ Placeholder default values will be used whenever new values are not provided as
|
||||
When using templates, be very careful about your selections as they can give broad access to your data if they are defined losely.
|
||||
|
||||
<div class="code-title code-request with-result">REQUEST</div>
|
||||
{% highlight html %}
|
||||
```html
|
||||
curl -X POST \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d @template.json \
|
||||
'https://documentation.cartodb.com/api/v1/map/named?api_key=APIKEY'
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
<div class="code-title">RESPONSE</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"templateid":"name",
|
||||
"template_id":"name",
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
### Instantiate
|
||||
|
||||
@ -387,19 +390,21 @@ Instantiating a map allows you to get the information needed to fetch tiles. Tha
|
||||
#### Definition
|
||||
|
||||
<div class="code-title notitle code-request"></div>
|
||||
{% highlight html %}
|
||||
```html
|
||||
POST /api/v1/map/named/:template_name
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Param
|
||||
|
||||
{% highlight javascript %}
|
||||
- **auth_token** optional, but required when `"method"` is set to `"token"`
|
||||
|
||||
```javascript
|
||||
// params.json
|
||||
{
|
||||
color: "#ff0000",
|
||||
cartodb_id: 3
|
||||
"color": "#ff0000",
|
||||
"cartodb_id": 3
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
The fields you pass as `params.json` depend on the variables allowed by the named map. If there are variables missing it will raise an error (HTTP 400)
|
||||
|
||||
@ -412,27 +417,27 @@ You can initialize a template map by passing all of the required parameters in a
|
||||
Valid credentials will be needed if required by the template.
|
||||
|
||||
<div class="code-title code-request with-result">REQUEST</div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
curl -X POST \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d @params.json \
|
||||
'https://documentation.cartodb.com/api/v1/map/named/@template_name?auth_token=AUTH_TOKEN'
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
<div class="code-title">Response</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"layergroupid": "docs@fd2861af@c01a54877c62831bb51720263f91fb33:123456788",
|
||||
"last_updated": "2013-11-14T11:20:15.000Z"
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
<div class="code-title">Error</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"error": "Some error string here"
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
You can then use the `layergroupid` for fetching tiles and grids as you would normally (see anonymous map section). However, you'll need to show the `auth_token`, if required by the template.
|
||||
|
||||
@ -443,24 +448,24 @@ There is also a special endpoint to be able to initialize a map using JSONP (for
|
||||
#### Definition
|
||||
|
||||
<div class="code-title notitle code-request"></div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
GET /api/v1/map/named/:template_name/jsonp
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Params
|
||||
|
||||
- **auth_token** *(optional)* If the named map needs auth
|
||||
- **auth_token** optional, but required when `"method"` is set to `"token"`
|
||||
- **config** Encoded JSON with the params for creating named maps (the variables defined in the template)
|
||||
- **lmza** This attribute contains the same as config but LZMA compressed. It cannot be used at the same time than `config`.
|
||||
- **callback:** JSON callback name
|
||||
|
||||
<div class="code-title code-request with-result">REQUEST</div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
curl 'https://documentation.cartodb.com/api/v1/map/named/:template_name/jsonp?auth_token=AUTH_TOKEN&callback=callback&config=template_params_json'
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
<div class="code-title">RESPONSE</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
callback({
|
||||
"layergroupid":"c01a54877c62831bb51720263f91fb33:0",
|
||||
"last_updated":"1970-01-01T00:00:00.000Z"
|
||||
@ -469,36 +474,36 @@ callback({
|
||||
"https": "https://cdb.com"
|
||||
}
|
||||
})
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
This takes the `callback` function (required), `auth_token` if the template needs auth, and `config` which is the variable for the template (in cases where it has variables).
|
||||
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
url += "config=" + encodeURIComponent(
|
||||
JSON.stringify({ color: 'red' });
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
The response is in this format:
|
||||
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
callback({
|
||||
layergroupid: "dev@744bd0ed9b047f953fae673d56a47b4d:1390844463021.1401",
|
||||
last_updated: "2014-01-27T17:41:03.021Z"
|
||||
})
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
### Update
|
||||
|
||||
#### Definition
|
||||
|
||||
<div class="code-title notitle code-request"></div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
PUT /api/v1/map/named/:template_name
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Params
|
||||
|
||||
Same params used to create a map.
|
||||
- **api_key** is required
|
||||
|
||||
#### Response
|
||||
|
||||
@ -511,29 +516,29 @@ Updating a named map removes all the named map instances so they need to be init
|
||||
#### Example
|
||||
|
||||
<div class="code-title code-request with-result">REQUEST</div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
curl -X PUT \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d @template.json \
|
||||
'https://documentation.cartodb.com/api/v1/map/named/:template_name?api_key=APIKEY'
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
<div class="code-title">RESPONSE</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"template_id": "@template_name"
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
If any template has the same name, it will be updated.
|
||||
|
||||
If a template with the same name does NOT exist, a 400 HTTP response is generated with an error in this format:
|
||||
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"error": "error string here"
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
Updating a template map will also remove all signatures from previously initialized maps.
|
||||
|
||||
@ -544,25 +549,29 @@ Delete the specified template map from the server and disables any previously in
|
||||
#### Definition
|
||||
|
||||
<div class="code-title notitle code-request"></div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
DELETE /api/v1/map/named/:template_name
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Params
|
||||
|
||||
- **api_key** is required
|
||||
|
||||
#### Example
|
||||
|
||||
<div class="code-title code-request">REQUEST</div>
|
||||
{% highlight bash %}
|
||||
curl -X DELETE 'https://documentation.cartodb.com/api/v1/map/named/:template_name?auth_token=AUTH_TOKEN'
|
||||
{% endhighlight %}
|
||||
```bash
|
||||
curl -X DELETE 'https://documentation.cartodb.com/api/v1/map/named/:template_name?api_key=APIKEY'
|
||||
```
|
||||
|
||||
<div class="code-title">RESPONSE</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"error": "Some error string here"
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
On success, a 204 (No Content) response would be issued. Otherwise a 4xx response with with an error will be returned:
|
||||
On success, a 204 (No Content) response would be issued. Otherwise a 4xx response with with an error will be returned.
|
||||
|
||||
### Listing Available Templates
|
||||
|
||||
@ -571,9 +580,9 @@ This allows you to get a list of all available templates.
|
||||
#### Definition
|
||||
|
||||
<div class="code-title notitle code-request"></div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
GET /api/v1/map/named/
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Params
|
||||
|
||||
@ -582,23 +591,23 @@ GET /api/v1/map/named/
|
||||
#### Example
|
||||
|
||||
<div class="code-title code-request with-result">REQUEST</div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
curl -X GET 'https://documentation.cartodb.com/api/v1/map/named?api_key=APIKEY'
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
<div class="code-title with-result">RESPONSE</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"template_ids": ["@template_name1","@template_name2"]
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
<div class="code-title">ERROR</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"error": "Some error string here"
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
### Getting a Specific Template
|
||||
|
||||
@ -607,9 +616,9 @@ This gets the definition of a template
|
||||
#### Definition
|
||||
|
||||
<div class="code-title notitle code-request"></div>
|
||||
{% highlight bash %}
|
||||
```bash
|
||||
GET /api/v1/map/named/:template_name
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Params
|
||||
|
||||
@ -618,20 +627,20 @@ GET /api/v1/map/named/:template_name
|
||||
#### Example
|
||||
|
||||
<div class="code-title code-request with-result">REQUEST</div>
|
||||
{% highlight bash %}
|
||||
curl -X GET 'https://documentation.cartodb.com/api/v1/map/named/:template_name?auth_token=AUTH_TOKEN'
|
||||
{% endhighlight %}
|
||||
```bash
|
||||
curl -X GET 'https://documentation.cartodb.com/api/v1/map/named/:template_name?api_key=APIKEY'
|
||||
```
|
||||
|
||||
<div class="code-title with-result">RESPONSE</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"template": {...} // see template.json above
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
<div class="code-title">ERROR</div>
|
||||
{% highlight javascript %}
|
||||
```javascript
|
||||
{
|
||||
"error": "Some error string here"
|
||||
}
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
@ -25,4 +25,4 @@ Windshaft-CartoDB adds the following attributes in the response object
|
||||
|
||||
## Stats tag
|
||||
|
||||
Windshaft-CartoDB adds support for a ``stat_tag`` element in the multilayer configuration to help [stats](Redis-stats-format) gathering.
|
||||
Windshaft-CartoDB adds support for a ``stat_tag`` element in the multilayer configuration to help [stats](https://github.com/CartoDB/Windshaft-cartodb/wiki/Redis-stats-format) gathering.
|
||||
|
639
npm-shrinkwrap.json
generated
639
npm-shrinkwrap.json
generated
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@
|
||||
"private": true,
|
||||
"name": "windshaft-cartodb",
|
||||
"version": "1.22.0",
|
||||
"version": "1.21.3",
|
||||
"description": "A map tile server for CartoDB",
|
||||
"keywords": [
|
||||
"cartodb"
|
||||
@ -25,14 +26,14 @@
|
||||
"node-varnish": "https://github.com/Vizzuality/node-varnish/tarball/0.3.0",
|
||||
"underscore" : "~1.6.0",
|
||||
"dot": "~1.0.2",
|
||||
"windshaft": "https://github.com/CartoDB/Windshaft/tarball/0.32.0",
|
||||
"windshaft": "https://github.com/CartoDB/Windshaft/tarball/0.32.4",
|
||||
"step": "~0.0.5",
|
||||
"request": "~2.9.203",
|
||||
"cartodb-redis": "https://github.com/CartoDB/node-cartodb-redis/tarball/0.11.0",
|
||||
"cartodb-psql": "https://github.com/CartoDB/node-cartodb-psql/tarball/0.4.0",
|
||||
"redis-mpool": "https://github.com/CartoDB/node-redis-mpool/tarball/0.3.0",
|
||||
"lzma": "~1.3.7",
|
||||
"log4js": "~0.6.17",
|
||||
"log4js": "https://github.com/CartoDB/log4js-node/tarball/cdb",
|
||||
"rollbar": "~0.3.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user