Merge pull request #850 from CartoDB/fix-named-map-force-all-layer

Fix named map regression: default to all layer
This commit is contained in:
Daniel 2018-01-16 19:22:56 +01:00 committed by GitHub
commit 767dde0b1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,9 +46,9 @@ NamedMapsController.prototype.register = function(app) {
cors(),
userMiddleware,
this.prepareContext,
this.getNamedMapProvider(),
this.getNamedMapProvider('NAMED_MAP_TILE'),
this.getAffectedTables(),
this.getTile(),
this.getTile('NAMED_MAP_TILE'),
this.setSurrogateKey(),
this.setCacheChannelHeader(),
this.setLastModifiedHeader(),
@ -85,6 +85,12 @@ NamedMapsController.prototype.getNamedMapProvider = function (label) {
const { user } = res.locals;
const { config, auth_token } = req.query;
const { template_id } = req.params;
// We force always the tile to be generated using PNG because
// is the only format we support by now
res.locals.format = 'png';
res.locals.layer = res.locals.layer || 'all';
const params = getRequestParams(res.locals);
this.namedMapProviderCache.get(user, template_id, config, auth_token, params, (err, namedMapProvider) => {
@ -177,7 +183,7 @@ NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function (la
}.bind(this);
};
NamedMapsController.prototype.getTile = function () {
NamedMapsController.prototype.getTile = function (label) {
return function getTileMiddleware (req, res, next) {
const { namedMapProvider } = res.locals;
@ -185,7 +191,7 @@ NamedMapsController.prototype.getTile = function () {
req.profiler.add(stats);
if (err) {
err.label = 'NAMED_MAP_TILE';
err.label = label;
return next(err);
}
@ -311,10 +317,6 @@ NamedMapsController.prototype.getImage = function (label) {
height = +height;
const format = req.params.format === 'jpg' ? 'jpeg' : 'png';
// We force always the tile to be generated using PNG because
// is the only format we support by now
res.locals.format = 'png';
res.locals.layer = res.locals.layer || 'all';
if (zoom !== undefined && center) {
return this.previewBackend.getImage(namedMapProvider, format, width, height, zoom, center,