diff --git a/docs/Map-API.md b/docs/Map-API.md index df411259..c137765f 100644 --- a/docs/Map-API.md +++ b/docs/Map-API.md @@ -4,10 +4,10 @@ The CartoDB Maps API allows you to generate maps based on data hosted in your Ca You can create two types of maps with the Maps API: -- **Anonymous maps** +- **Anonymous Maps** You can create maps 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/getting-started/). -- **Named maps** +- **Named Maps** There are also 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. ## Documentation diff --git a/docs/MapConfig-NamedMaps-extension.md b/docs/MapConfig-NamedMaps-extension.md index a6418174..2793faec 100644 --- a/docs/MapConfig-NamedMaps-extension.md +++ b/docs/MapConfig-NamedMaps-extension.md @@ -6,7 +6,7 @@ This specification describes an extension for # 2. Changes over specification -This extension introduces a new layer type so it's possible to use a named map by its name as a layer. +This extension introduces a new layer type so it's possible to use a Named Map by its name as a layer. ## 2.1 Named layers definition @@ -21,18 +21,18 @@ This extension introduces a new layer type so it's possible to use a named map b options: { // REQUIRED - // string, the name for the named map to use + // string, the name for the Named Map to use name: "world_borders", // OPTIONAL - // object, the replacement values for the named map's template placeholders + // object, the replacement values for the Named Map's template placeholders // See https://github.com/CartoDB/Windshaft-cartodb/blob/master/docs/Map-API.md#instantiate-1 for more details config: { "color": "#000" }, // OPTIONAL - // string array, the authorized tokens in case the named map has auth method set to `token` + // string array, the authorized tokens in case the Named Map has auth method set to `token` // See https://github.com/CartoDB/Windshaft-cartodb/blob/master/docs/Map-API.md#named-maps-1 for more details auth_tokens: [ "token1", diff --git a/docs/anonymous_maps.md b/docs/anonymous_maps.md index 02d35dc9..cdf6cad4 100644 --- a/docs/anonymous_maps.md +++ b/docs/anonymous_maps.md @@ -1,6 +1,6 @@ # Anonymous Maps -Anonymous maps allows you to instantiate a map given SQL and CartoCSS. It also allows you to add interaction capabilities using [UTF Grid.](https://github.com/mapbox/utfgrid-spec) +Anonymous Maps allows you to instantiate a map given SQL and CartoCSS. It also allows you to add interaction capabilities using [UTF Grid.](https://github.com/mapbox/utfgrid-spec) ## Instantiate @@ -161,7 +161,7 @@ GET /api/v1/map?callback=method Param | Description --- | --- -config | Encoded JSON with the params for creating named maps (the variables defined in the template). +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 `config`. callback | JSON callback name. @@ -189,4 +189,4 @@ callback({ ## 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 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. +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 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. diff --git a/docs/general_concepts.md b/docs/general_concepts.md index 859c6df9..506bef87 100644 --- a/docs/general_concepts.md +++ b/docs/general_concepts.md @@ -4,7 +4,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. Using HTTPS is mandatory when you are performing requests that include your `api_key`. diff --git a/docs/named_maps.md b/docs/named_maps.md index 0b68a408..6a68b73b 100644 --- a/docs/named_maps.md +++ b/docs/named_maps.md @@ -1,18 +1,20 @@ # Named Maps -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. You can create named maps from private data, and users without an API Key can view your Named Map (while keeping your data private). The Named map workflow consists of making a call to your database, referencing a table, inserting your variables into the template where placeholders are defined, and creating custom queries. +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. You can create Named Maps from private data, and users without an API Key can view your Named Map (while keeping your data private). -The main two differences compared to anonymous maps are: +The Named Map workflow consists of uploading a MapConfig file to CartoDB servers, to select data from your CartoDB user database by using SQL. The response back from the API provides the name of your MapConfig as a template map; which you can then use to create your Named Map details, or fetch XYZ tiles directly for Named Maps. You can use also the MapConfig that you uploaded to create a map using [CartoDB.js](#use-cartodbjs-to-create-named-maps) for Named Maps. -- **auth layer** - This allows you to control who is able to see the map based on a token auth +The main differences, compared to Anonymous Maps, is that Named Maps include: + +- **auth token** + This allows you to control who is able to see the map based on an auth token, and create a secure Named Map with password-protection. - **templates** - Since the MapConfig is static it can contain some variables so the client can modify the map's appearance using those variables. + The MapConfig generated template map is static and contains placeholders, enabling you to modify your map's appearance by using variables. Templates 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 argument](#arguments)). -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). + Uploading a MapConfig produces a template map for your Named Maps. Such as MapConfigs are uploaded to the server, "template".json files are uploaded to the server for Named Maps. -**Note:** There is a limit of 4,096 named maps allowed per account. If you need to create more Named maps, it is recommended to use templates. +**Note:** There is a limit of 4,096 Named Maps allowed per account. If you need to create more Named Maps, it is recommended to use template maps instead of uploading multiple [Named Map MapConfigs](http://docs.cartodb.com/cartodb-platform/maps-api/mapconfig/#named-map-layer-options). ## Create @@ -30,6 +32,8 @@ api_key | is required #### template.json +The response back from the API provides the name of your MapConfig as a template, enabling you to create the Named Map details by inserting your variables into the template where placeholders are defined, and create custom queries using SQL. The `name` argument defines how to name this "template_name".json. Note that there are some requirements for how to name a Named Map template. See the [`name`](#arguments) argument description for details. + ```javascript { "version": "0.0.1", @@ -84,16 +88,15 @@ api_key | is required Params | Description --- | --- -name | There can be at most _one_ template with the same name for any user. Valid names start with a letter or a number, and only contain letters, numbers, dashes (-) or underscores (_). +name | There can only be _one_ template with the same name for any user. Valid names start with a letter or a number, and only contain letters, numbers, dashes (-), or underscores (_). This is specific to the name of your Named Map [template.json](#templatejson). auth | --- | --- -|_ 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. Variables 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 [MapConfig File Format](http://docs.cartodb.com/cartodb-platform/maps-api/mapconfig/) for more info. - -view (optional) | extra keys to specify the compelling area for the map. It can be used to have a static preview of a named map without having to instantiate it. It is possible to specify it with `center` + `zoom` or with a bounding box `bbox`. Center+zoom takes precedence over bounding box. +|_ method | `"token"` or `"open"` (`"open"` is the default if no method is specified. Use `"token"` to password-protect your map). +|_ valid_tokens | when `"method"` is set to `"token"`, the values listed here allow you to instantiate the Named Map. See this [example](http://docs.cartodb.com/faqs/manipulating-your-data/#how-to-create-a-password-protected-named-map) for how to create a password-protected map. +placeholders | Placeholders are variables that can be placed in your template.json file's SQL or CartoCSS. +layergroup | the layergroup configurations, as specified in the MapConfig. See [MapConfig File Format](http://docs.cartodb.com/cartodb-platform/maps-api/mapconfig/) for more information. +view (optional) | extra keys to specify the view area for the map. It can be used to have a static preview of a Named Map without having to instantiate it. It is possible to specify it with `center` + `zoom` or with a bounding box `bbox`. Center+zoom takes precedence over bounding box. --- | --- |_ zoom | The zoom level to use @@ -109,9 +112,9 @@ view (optional) | extra keys to specify the compelling area for the map. It can |_ |_ east | UpperCorner longitude for the bounding box, in decimal degrees (aka most eastern) |_ |_ north | UpperCorner latitude for the bounding box, in decimal degrees (aka most northern) -### Template Format +### Placeholder Format -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 +Placeholders are variables that can be placed in your MapConfig, and template.json file's, SQL or CartoCSS options. Placeholders need to be defined with a `type` and a default value for MapConfigs. See details about defining a MapConfig `type` for [Layergoup configurations](http://docs.cartodb.com/cartodb-platform/maps-api/mapconfig/#layergroup-configurations). 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. @@ -121,7 +124,7 @@ Valid placeholder names start with a letter and can only contain letters, number <%= my_color %> ``` -The set of supported placeholders for a template will need to be explicitly defined with a specific type and default value for each. +The set of supported placeholders for a template need to be explicitly defined with a specific type, and default value, for each placeholder. ### Placeholder Types @@ -134,9 +137,9 @@ sql_ident | internal double-quotes will be sql-escaped number | can only contain numerical representation css_color | can only contain color names or hex-values -Placeholder default values will be used whenever new values are not provided as options at the time of creation on the client. They can also be used to test the template by creating a default version with new options provided. +Placeholder default values will be used whenever new values are not provided as options, at the time of creation on the client. They can also be used to test the template by creating a default version with new options provided. -When using templates, be very careful about your selections as they can give broad access to your data if they are defined losely. +When using templates, be very careful about your selections as they can give broad access to your data if they are defined loosely. #### Call @@ -157,7 +160,7 @@ curl -X POST \ ## Instantiate -Instantiating a map allows you to get the information needed to fetch tiles. That temporal map is an anonymous map. +Instantiating a map allows you to get the information needed to fetch tiles. That temporal map is an Anonymous Map. #### Definition @@ -179,15 +182,15 @@ auth_token | optional, but required when `"method"` is set to `"token"` } ``` -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) +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) -- **auth_token** *optional* if the named map needs auth +- **auth_token** *optional* if the Named Map needs password-protection ### Example You can initialize a template map by passing all of the required parameters in a POST to `/api/v1/map/named/:template_name`. -Valid credentials will be needed if required by the template. +Valid credentials will be needed, if required by the template. #### Call @@ -216,7 +219,7 @@ curl -X POST \ } ``` -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. +You can then use the `layergroupid` for fetching tiles and grids as you would normally (see [Anonymous Maps](http://docs.cartodb.com/cartodb-platform/maps-api/anonymous-maps/)). However, you will need to show the `auth_token`, if required by the template. ## Using JSONP @@ -233,7 +236,7 @@ GET /api/v1/map/named/:template_name/jsonp Params | Description --- | --- 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) +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 @@ -290,9 +293,9 @@ api_key | is required Same as updating a map. -### Other Info +### Other Information -Updating a named map removes all the named map instances so they need to be initialized again. +Updating a Named Map removes all the Named Map instances, so they need to be initialized again. ### Example @@ -325,7 +328,7 @@ If a template with the same name does NOT exist, a 400 HTTP response is generate ## Delete -Delete the specified template map from the server and it disables any previously initialized versions of the map. +Deletes the specified template map from the server, and disables any previously initialized versions of the map. #### Definition @@ -425,7 +428,7 @@ curl -X GET 'https://documentation.cartodb.com/api/v1/map/named/:template_name?a ```javascript { - "template": {...} // see template.json above + "template": {...} // see [template.json](#templatejson) } ``` @@ -438,7 +441,7 @@ curl -X GET 'https://documentation.cartodb.com/api/v1/map/named/:template_name?a ``` ## Use CartoDB.js to Create Named Maps -Named maps can be used with CartoDB.js by specifying a named map in a layer source as follows. Named maps are treated almost the same as other layer source types in most other ways. +Named Maps can be used with CartoDB.js, by specifying a Named Map in a layer source as follows. Named Maps are treated almost the same as other layer source types. ```js var layerSource = { @@ -458,18 +461,18 @@ cartodb.createLayer('map_dom_id',layerSource) ``` -[CartoDB.js](http://docs.cartodb.com/cartodb-platform/cartodb-js/) has methods for accessing your named maps. +[CartoDB.js](http://docs.cartodb.com/cartodb-platform/cartodb-js/) has methods for accessing your Named Maps. 1. [layer.setParams()](http://docs.cartodb.com/cartodb-platform/cartodb-js/api-methods/#layersetparamskey-value) allows you to change the template variables (in the placeholders object) via JavaScript - **Note:** The CartoDB.js `layer.setParams()` function is not supported when using Named maps for Torque. + **Note:** The CartoDB.js `layer.setParams()` function is not supported when using Named Maps for Torque. 2. [layer.setAuthToken()](http://docs.cartodb.com/cartodb-platform/cartodb-js/api-methods/#layersetauthtokenauthtoken) allows you to set the auth tokens to create the layer ### Complete Examples of Named Maps created with CartoDB.js -- [Named map selectors with interaction](http://bl.ocks.org/ohasselblad/515a8af1f99d5e690484) +- [Named Map selectors with interaction](http://bl.ocks.org/ohasselblad/515a8af1f99d5e690484) -- [Named map with interactivity and config file used to create it](http://bl.ocks.org/ohasselblad/d1a45b8ff5e7bd90cd68) +- [Named Map with interactivity and config file used to create it](http://bl.ocks.org/ohasselblad/d1a45b8ff5e7bd90cd68) - [Toggling sublayers in a Named Map](http://bl.ocks.org/ohasselblad/c1a0f4913610eec53cd3) diff --git a/docs/quickstart.md b/docs/quickstart.md index 00f084df..057a74e4 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -1,8 +1,8 @@ # Quickstart -## Anonymous maps +## Anonymous Maps -Here is an example of how to create an anonymous map with JavaScript: +Here is an example of how to create an Anonymous Map with JavaScript: ```javascript var mapconfig = { @@ -31,9 +31,9 @@ $.ajax({ }) ``` -## Named maps +## Named Maps -Let's create a named map using some private tables in a CartoDB account. +Let's create a Named Map using some private tables in a CartoDB account. The following map config sets up a map of European countries that have a white fill color: ```javascript @@ -56,7 +56,7 @@ The following map config sets up a map of European countries that have a white f } ``` -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: +The MapConfig 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: #### Call diff --git a/docs/static_maps_api.md b/docs/static_maps_api.md index 9c3c2d3d..9fc7ae4f 100644 --- a/docs/static_maps_api.md +++ b/docs/static_maps_api.md @@ -1,10 +1,10 @@ # Static Maps API -The Static Maps API can be initiated using both named and anonymous maps using the 'layergroupid' token. The API can be used to create static images of parts of maps and thumbnails for use in web design, graphic design, print, field work, and many other applications that require standard image formats. +The Static Maps API can be initiated using both Named and Anonymous Maps using the 'layergroupid' token. The API can be used to create static images of parts of maps and thumbnails for use in web design, graphic design, print, field work, and many other applications that require standard image formats. ## Maps API endpoints -Begin by instantiating either a named or anonymous map using the `layergroupid token` as demonstrated in the Maps API documentation above. The `layergroupid` token calls to the map and allows for parameters in the definition to generate static images. +Begin by instantiating either a Named or Anonymous Map using the `layergroupid token` as demonstrated in the Maps API documentation above. The `layergroupid` token calls to the map and allows for parameters in the definition to generate static images. ### Zoom + center @@ -60,7 +60,7 @@ Note: you can see this endpoint as GET /api/v1/map/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format` ``` -### Named map +### Named Map #### Definition @@ -72,7 +72,7 @@ GET /api/v1/map/static/named/:name/:width/:height.:format Param | Description --- | --- -:name | the name of the named map +:name | the name of the Named Map :width | the width in pixels for the output image :height | the height in pixels for the output image :height | the height in pixels for the output image @@ -81,7 +81,7 @@ Param | Description --- | --- |_ jpg | will have a default quality of 85. -A named maps static image will get its constraints from the [view in the template](#Arguments), if `view` is not present it will estimate the extent based on the involved tables otherwise it fallback to `"zoom": 1`, `"lng": 0` and `"lat": 0`. +A Named Maps static image will get its constraints from the [`view` argument of the Create Named Map function](http://docs.cartodb.com/cartodb-platform/maps-api/named-maps/#arguments). If `view` is not defined, it will estimate the extent based on the involved tables, otherwise it fallbacks to `"zoom": 1`, `"lng": 0` and `"lat": 0`. #### Layers