From 853c2b4b852c7c02d04979b4a2604fe15ff25027 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 29 Apr 2015 17:17:46 +0200 Subject: [PATCH 1/6] Adds new route for named maps static previews --- docs/Routes.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/Routes.md b/docs/Routes.md index fa435d7b..79f22a3d 100644 --- a/docs/Routes.md +++ b/docs/Routes.md @@ -38,6 +38,9 @@ This document list all routes available in Windshaft-cartodb Maps API server. 1. `GET (?:/api/v1/map/named|/user/:user/api/v1/map/named|/tiles/template) {:user(f)} (1)`
Notes: List named maps (w/ API KEY) [1] +1. `GET (?:/api/v1/map|/user/:user/api/v1/map|/tiles/layergroup)/static/named/:template_id/:width/:height.:format {:user(f),:template_id(f),:width(f),:height(f),:format(f)} (1)` +
Notes: Static map for named maps + 1. `GET /health {} (1)`
Notes: Healt check From 25ae09b2c5f1a986eccf55a6c846e460aa33b803 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 29 Apr 2015 17:18:36 +0200 Subject: [PATCH 2/6] Update patch to generate routes document --- docs/Routes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Routes.md b/docs/Routes.md index 79f22a3d..c29f9f1e 100644 --- a/docs/Routes.md +++ b/docs/Routes.md @@ -76,10 +76,10 @@ Something like the following patch should do the trick ```javascript diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js -index 477a4c2..f69eebb 100644 +index b9429a2..e6cc5f9 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js -@@ -242,6 +242,20 @@ var CartodbWindshaft = function(serverOptions) { +@@ -212,6 +212,20 @@ var CartodbWindshaft = function(serverOptions) { } }); From c97c65de34b243d07fb010fa24595d0bc37383fc Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 18 May 2015 11:24:06 +0200 Subject: [PATCH 3/6] Fixes multilayer link --- docs/MultiLayer-API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/MultiLayer-API.md b/docs/MultiLayer-API.md index 740d56f1..793a60a9 100644 --- a/docs/MultiLayer-API.md +++ b/docs/MultiLayer-API.md @@ -1,4 +1,4 @@ -The Windshaft-CartoDB MultiLayer API extends the [Windshaft MultiLayer API](https://github.com/Vizzuality/Windshaft/wiki/Multilayer-API) in a few ways. +The Windshaft-CartoDB MultiLayer API extends the [Windshaft MultiLayer API](https://github.com/CartoDB/Windshaft/blob/master/doc/Multilayer-API.md) in a few ways. ## Last modification timestamp embedded in the token From 2bd9aece354e6310e5d4a257fa2f1b5d150684e6 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 3 Jun 2015 17:00:05 -0400 Subject: [PATCH 4/6] Add header for zoom + center in static maps --- docs/Map-API.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/Map-API.md b/docs/Map-API.md index 54ff18c6..67db68e6 100644 --- a/docs/Map-API.md +++ b/docs/Map-API.md @@ -747,6 +747,8 @@ The Static Maps API can be initiated using both named and anonymous maps using t 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 + ##### Definition
From dfc9a6fbb447bd4ce65357390dd3c2bbe8849559 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 3 Jun 2015 17:00:42 -0400 Subject: [PATCH 5/6] Documentation about `view` in named maps' templates Closes #287 --- docs/Map-API.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/Map-API.md b/docs/Map-API.md index 67db68e6..faa5e84d 100644 --- a/docs/Map-API.md +++ b/docs/Map-API.md @@ -398,6 +398,19 @@ POST /api/v1/map/named } } ] + }, + "view": { + "zoom": 4, + "center": { + "lng": 0, + "lat": 0 + }, + "bounds": { + "west": -45, + "south": -45, + "east": 45, + "north": 45 + } } } ``` @@ -410,6 +423,16 @@ POST /api/v1/map/named - **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 documentation](https://github.com/CartoDB/Windshaft/blob/master/doc/MapConfig-1.1.0.md) 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. + - **zoom** The zoom level to use + - **center** + - **lng** The longitude to use for the center + - **lat** The latitude to use for the center + - **bounds** + - **west**: The western point for the bounding box + - **south**: The southern point for the bounding box + - **east**: The eastern point for the bounding box + - **north**: The northern point for the bounding box #### Template Format From d5d76f9c63f3b1dcc691776c5af9abae6d4af33e Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 3 Jun 2015 17:09:10 -0400 Subject: [PATCH 6/6] Adds information about named map static images endpoint --- docs/Map-API.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/Map-API.md b/docs/Map-API.md index faa5e84d..6ffba1c1 100644 --- a/docs/Map-API.md +++ b/docs/Map-API.md @@ -818,6 +818,25 @@ Note: you can see this endpoint as: GET /api/v1/map/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format` ``` +#### Named map + +##### Definition + +
+```bash +GET /api/v1/map/static/named/:name/:width/:height.:format +``` + +##### Params + +* **: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 +* **:format**: the format for the image, supported types: `png`, `jpg` + * **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`. + ####Layers The Static Maps API allows for multiple layers of incorporation into the `MapConfig` to allow for maximum versatility in creating a static map. The examples below were used to generate the static image example in the next section, and appear in the specific order designated.