From daa94dc8062d591c74e63047917f9ded7b2eb5e2 Mon Sep 17 00:00:00 2001 From: Petr Sloup Date: Wed, 4 May 2016 13:13:37 +0200 Subject: [PATCH] Chain attributions from mbtiles into the tilejson of the rendered tiles --- src/serve_rendered.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/serve_rendered.js b/src/serve_rendered.js index 375a7e1..95f2ae7 100644 --- a/src/serve_rendered.js +++ b/src/serve_rendered.js @@ -140,6 +140,7 @@ module.exports = function(options, repo, params, id) { var tileJSON = { 'tilejson': '2.0.0', 'name': styleJSON.name, + 'attribution': '', 'basename': id, 'minzoom': 0, 'maxzoom': 20, @@ -147,6 +148,7 @@ module.exports = function(options, repo, params, id) { 'format': 'png', 'type': 'baselayer' }; + var attributionOverride = params.tilejson && params.tilejson.attribution; Object.assign(tileJSON, params.tilejson || {}); tileJSON.tiles = params.domains || options.domains; utils.fixTileJSONCenter(tileJSON); @@ -190,6 +192,13 @@ module.exports = function(options, repo, params, id) { map.sources[name].emptyTile = buffer; }); } + if (!attributionOverride && + source.attribution && source.attribution.length > 0) { + if (tileJSON.attribution.length > 0) { + tileJSON.attribution += '; '; + } + tileJSON.attribution += source.attribution; + } callback(null); }); });