Skip to content

Commit

Permalink
geosolutions-it#9346 Print plugin is not showing the printable area
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap committed Aug 22, 2023
1 parent 414f295 commit 059dd82
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
5 changes: 3 additions & 2 deletions web/client/plugins/Print.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,10 @@ export default {
};
getPreviewResolution = (zoom, projection) => {
const dpu = dpi2dpu(DEFAULT_SCREEN_DPI, projection);
const roundZoom = Math.round(zoom);
const scale = this.props.useFixedScales
? getPrintScales(this.props.capabilities)[zoom]
: this.props.scales[zoom];
? getPrintScales(this.props.capabilities)[roundZoom]
: this.props.scales[roundZoom];
return scale / dpu;
};
getLayout = (props) => {
Expand Down
41 changes: 41 additions & 0 deletions web/client/plugins/__tests__/Print-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,4 +441,45 @@ describe('Print Plugin', () => {
}
});
});

it("test configuration with not round zoom level", (done) => {
const actions = {
onPrint: () => {}
};
let spy = expect.spyOn(actions, "onPrint");
getPrintPlugin({
layers: [
{visibility: true, type: "osm"},
{id: "test", url: "/test", name: "test", type: "wms", visibility: true, maxResolution: 500000}
],
projection: "EPSG:4326",
state: {
...initialState,
map: {
...initialState.map,
zoom: 5.1
}
}
}).then(({ Plugin }) => {
try {
ReactDOM.render(<Plugin
pluginCfg={{
onPrint: actions.onPrint
}}
defaultBackground={["osm", "empty"]}
/>, document.getElementById("container"));
const submit = document.getElementsByClassName("print-submit").item(0);
expect(submit).toExist();
ReactTestUtils.Simulate.click(submit);
setTimeout(() => {
expect(spy.calls.length).toBe(1);
expect(spy.calls[0].arguments[1].layers.length).toBe(1);
expect(spy.calls[0].arguments[1].layers[0].layers).toEqual(["test"]);
done();
}, 0);
} catch (ex) {
done(ex);
}
});
});
});

0 comments on commit 059dd82

Please sign in to comment.