The CARTO Maps API allows you to generate maps based on data hosted in your CARTO account.

This component is still under support but it will not be further developed. We don’t recommend starting new projects with it as it will eventually become deprecated. Instead, learn more about our new APIs here

MapConfig Analyses Extension

1. Purpose

This specification describes an extension for MapConfig 1.4.0 version.

2. Changes over specification

This extension targets layers with sql option, including layer types: cartodb, mapnik, and torque.

It extends MapConfig with a new attribute: analyses.

2.1 Analyses attribute

The new analyses attribute must be an array of analyses as per camshaft. Each analysis must adhere to the camshaft-reference specification.

Each node can have an id that can be later references to consume the query from MapConfig’s layers.

Basic analyses example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[
    {
        // REQUIRED
        // string, `id` free identifier that can be reference from any layer
        "id": "HEAD",
        // REQUIRED
        // string, `type` camshaft's analysis type
        "type": "source",
        // REQUIRED
        // object, `params` will depend on `type`, check camshaft-reference for more information
        "params": {
            "query": "select * from your_table"
        }
    }
]

2.2. Integration with layers

As pointed before an analysis node id can be referenced from layers to consume its output query.

The layer consuming the output must reference it with the following option:

1
2
3
4
5
6
7
8
9
10
11
{
    "options": {
        // REQUIRED
        // object, `source` as in the future we might want to have other source options
        "source": {
            // REQUIRED
            // string, `id` the analysis node identifier
            "id": "HEAD"
        }
    }
}

2.3. Complete example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
    "version": "1.4.0",
    "layers": [
        {
            "type": "cartodb",
            "options": {
                "source": {
                    "id": "HEAD"
                },
                "cartocss": "...",
                "cartocss_version": "2.3.0"
            }
        }
    ],
    "analyses": [
        {
            "id": "HEAD",
            "type": "source",
            "params": {
                "query": "select * from your_table"
            }
        }
    ]
}

History

1.0.0

  • Initial version