Anonymous Maps allows you to instantiate a map given SQL and CartoCSS. It also allows you to add interaction capabilities using UTF Grid.
See MapConfig File Formats for details.
The response includes:
|layergroupid||The ID for that map, used to compose the URL for the tiles. The final URL is:
|updated_at||The ISO date of the last time the data involved in the query was updated.|
|metadata||Includes information about the layers.|
|cdn_url||URLs to fetch the data using the best CDN for your zone.|
Retrieve resources from the layergroup
When you have a layergroup, there are several resources for retrieving layergoup details such as, accessing Mapnik tiles, getting individual layers, accessing defined Attributes, and blending and layer selection.
These tiles will get just the Mapnik layers. To get individual layers, see the following section.
The MapConfig specification holds the layers definition in a 0-based index. Layers can be requested individually in different formats depending on the layer type.
Individual layers can be accessed using that 0-based index. For UTF grid tiles:
In this case,
layer as 0 returns the UTF grid tiles/attributes for layer 0, the only layer in the example MapConfig.
If the MapConfig had a Torque layer at index 1 it could be possible to request it with:
Attributes defined in
Which returns JSON with the attributes defined, like:
Blending and layer selection
Note: currently format is limited to
layer_filter can be used to select some layers to be rendered together.
layer_filter supports two formats:
layer_filter will blend all layers in the layergroup
- Filter by layer index
A list of comma separated layer indexes can be used to just render a subset of layers. For example
0,3,4 will filter and blend layers with indexes 0, 3, and 4.
Some notes about filtering:
- Invalid index values or out of bounds indexes will end in
Invalid layer filteringerrors.
- Ordering is not considered. So right now filtering layers 0,3,4 is the very same thing as filtering 3,4,0. As this may change in the future it is recommended to always select the layers in ascending order so you will get a consistent behavior in the future.
The JSONP endpoint is provided in order to allow web browsers access which don’t support CORS.
|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 as
|callback||JSON callback name.|
Anonymous Maps cannot be removed by an API call. They will expire after about five minutes, or 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 and 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.