Made explicit to recreate named-map-provider

This commit is contained in:
Daniel García Aubert 2016-09-01 16:42:06 +02:00
parent b0990a1132
commit 7c6a58cd30

View File

@ -142,7 +142,7 @@ NamedMapsController.prototype.staticMap = function(req, res) {
namedMapProvider = _namedMapProvider; namedMapProvider = _namedMapProvider;
self.prepareLayerFilterFromPreviewLayers(req.params, namedMapProvider, this); self.prepareLayerFilterFromPreviewLayers(cdbUser, req, namedMapProvider, this);
}, },
function prepareImageOptions(err) { function prepareImageOptions(err) {
assert.ifError(err); assert.ifError(err);
@ -190,7 +190,8 @@ NamedMapsController.prototype.staticMap = function(req, res) {
); );
}; };
NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function (params, namedMapProvider, callback) { NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function (cdbUser, req, namedMapProvider, callback) {
var self = this;
namedMapProvider.getTemplate(function (err, template) { namedMapProvider.getTemplate(function (err, template) {
if (err) { if (err) {
return callback(err); return callback(err);
@ -209,12 +210,22 @@ NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function (pa
} }
}); });
if (layerVisibilityFilter.length) { if (!layerVisibilityFilter.length) {
// overwrite 'all' default filter return callback();
params.layer = layerVisibilityFilter.join(',');
} }
callback(); // overwrites 'all' default filter
req.params.layer = layerVisibilityFilter.join(',');
// recreates the provider
self.namedMapProviderCache.get(
cdbUser,
req.params.template_id,
req.query.config,
req.query.auth_token,
req.params,
callback
);
}); });
}; };