Skip to content

Commit

Permalink
feat(core): chnge which layers to hide map export
Browse files Browse the repository at this point in the history
Hide all feature layers in modern browsers since we are getting an image of them using html2canvas;
Hide only user-added layers in IE9-10 as we can't get images of them using html2canvas.

Signed-off-by: Aleksuei Riabtsev <aleksuei.riabtsev@ec.gc.ca>
  • Loading branch information
AleksueiR committed Jul 6, 2015
1 parent 8ccc923 commit 467c07a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/js/RAMP/Modules/imageExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,18 @@ define([

//go through feature layer config
RAMP.config.layers.feature.forEach(function (fl) {
var flObj = RAMP.layerRegistry[fl.id];
var flObj = RAMP.layerRegistry[fl.id],
youHaveIE = RAMP.flags.brokenWebBrowser || RAMP.flags.ie10client;

//find if feature layer, user added, visible, and has no URL
if (flObj.ramp.user && flObj.visible && !(flObj.url)) {
//turn off visibility. remember the layer
flObj.setVisibility(false);
visState.layers.push(flObj);
if (flObj.visible) { // turn off all visible feature layers, unless you have IE - then turn off only visible user layers

if (youHaveIE && flObj.ramp.user && !(flObj.url) || !youHaveIE) {
//turn off visibility. remember the layer
flObj.setVisibility(false);
visState.layers.push(flObj);
}

}
});
}
Expand Down Expand Up @@ -334,15 +339,11 @@ define([

printTask.on('complete', function (event) {
//console.log('PRINT RESULT: ' + event.result.url);
//turn hidden layers back on
restoreFileLayers();
def.resolve(event);
});

printTask.on('error', function (event) {
//console.log('PRINT FAILED: ' + event.error.message);
//turn hidden layers back on
restoreFileLayers();
def.reject(event);
});

Expand All @@ -367,6 +368,8 @@ define([
def.reject(event);
}

restoreFileLayers();

return {
promise: def.promise,
exportOptions: template.exportOptions
Expand Down

0 comments on commit 467c07a

Please sign in to comment.