diff --git a/web/client/actions/config.js b/web/client/actions/config.js index 435af8feff..1d2d13d6bf 100644 --- a/web/client/actions/config.js +++ b/web/client/actions/config.js @@ -7,6 +7,7 @@ */ var axios = require('../libs/ajax'); +var ConfigUtils = require('../utils/ConfigUtils'); const MAP_CONFIG_LOADED = 'MAP_CONFIG_LOADED'; const MAP_CONFIG_LOAD_ERROR = 'MAP_CONFIG_LOAD_ERROR'; @@ -31,10 +32,14 @@ function configureError(e) { }; } -function loadMapConfig(configName, mapId) { +function loadMapConfig(configName, mapId, permalinkObj) { return (dispatch) => { return axios.get(configName).then((response) => { if (typeof response.data === 'object') { + if (permalinkObj) { + ConfigUtils.setPermalinkLayersVisibility(response.data.map.layers, permalinkObj.permalinkLayers.layers); + assign(response.data.map, permalinkObj.permalinkExtent); + } dispatch(configureMap(response.data, mapId)); } else { try { diff --git a/web/client/utils/ConfigUtils.js b/web/client/utils/ConfigUtils.js index 749c7b9316..f035c5da91 100644 --- a/web/client/utils/ConfigUtils.js +++ b/web/client/utils/ConfigUtils.js @@ -325,6 +325,11 @@ var ConfigUtils = { }, getConfigProp: function(prop) { return defaultConfig[prop]; + }, + setPermalinkLayersVisibility: function(originalLayers, newLayers) { + return originalLayers.map((originalLayer) => { + return assign({}, originalLayer, {visibility: newLayers.filter((layer) => originalLayer.id === layer).length > 0 ? true : false}); + }); } };