diff --git a/src/gm3/actions/mapSource.js b/src/gm3/actions/mapSource.js index 3742c17a..e5c49f39 100644 --- a/src/gm3/actions/mapSource.js +++ b/src/gm3/actions/mapSource.js @@ -510,11 +510,18 @@ function isMapSourceActive(mapSource) { /** Get the list of all map-sources which have a * layer that is on. */ -export function getActiveMapSources(mapSources, onlyPrintable = false) { +export function getActiveMapSources( + mapSources, + onlyPrintable = false, + includeSelection = true +) { const active = []; const allMaps = !onlyPrintable; for (const ms in mapSources) { - if (isMapSourceActive(mapSources[ms])) { + if ( + isMapSourceActive(mapSources[ms]) && + (includeSelection || ms !== "selection") + ) { if (allMaps || mapSources[ms].printable) { active.push(ms); } diff --git a/src/gm3/components/map/index.js b/src/gm3/components/map/index.js index baf4f131..edb1c6bc 100644 --- a/src/gm3/components/map/index.js +++ b/src/gm3/components/map/index.js @@ -303,9 +303,11 @@ class Map extends React.Component { refreshMapSources() { // get the list of current active map-sources const printOnly = this.props.printOnly === true; + const includeSelection = this.props.includeSelection !== false; const activeMapSources = mapSourceActions.getActiveMapSources( this.props.mapSources, - printOnly + printOnly, + includeSelection ); // annoying O(n^2) iteration to see if the mapsource needs diff --git a/src/gm3/components/print/printImage.js b/src/gm3/components/print/printImage.js index 6b77df11..8cbd7a6b 100644 --- a/src/gm3/components/print/printImage.js +++ b/src/gm3/components/print/printImage.js @@ -95,6 +95,7 @@ const PrintImage = (props) => { center={center} resolution={rez} printOnly={true} + includeSelection={props.includeSelection} mapRenderedCallback={() => { if (parentRef.current) { setImage(getImage(parentRef.current, [props.width, props.height])); @@ -108,6 +109,7 @@ const PrintImage = (props) => { PrintImage.defaultProps = { width: 600, height: 400, + includeSelection: true, }; const mapToProps = (state) => ({ diff --git a/src/gm3/components/print/printModal.js b/src/gm3/components/print/printModal.js index e165d9f1..c65f072b 100644 --- a/src/gm3/components/print/printModal.js +++ b/src/gm3/components/print/printModal.js @@ -121,6 +121,7 @@ export class PrintModal extends Modal { layout: 0, resolution: 1, layouts: props.layouts ? props.layouts : DefaultLayouts, + includeSelection: "true", }; } @@ -550,6 +551,24 @@ export class PrintModal extends Modal { ); } + /** Choose whether to include the selected layers in the output. + */ + renderIncludeSelection(t) { + return ( + + ); + } + renderBody() { // small set of CSS hacks to keep the print map // invisible but drawn. @@ -605,6 +624,10 @@ export class PrintModal extends Modal { {this.renderResolutionSelect(t)}
++ + {this.renderIncludeSelection(t)} +
)} @@ -620,6 +643,7 @@ export class PrintModal extends Modal { width={mapSize.width} height={mapSize.height} store={this.props.store} + includeSelection={this.state.includeSelection === "true"} /> diff --git a/src/gm3/lang/en.json b/src/gm3/lang/en.json index 277a2d0d..2810ebd9 100644 --- a/src/gm3/lang/en.json +++ b/src/gm3/lang/en.json @@ -117,5 +117,8 @@ "zoomto-results" : "Zoom to results", "zoomto-tip" : "Zoom to layer extents.", "zoom-in" : "Zoom In", - "zoom-out" : "Zoom Out" + "zoom-out" : "Zoom Out", + "include-selection": "Include selection", + "yes": "Yes", + "no": "No" }