Skip to content

Instantly share code, notes, and snippets.

@ThomasJunk
Created July 25, 2019 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasJunk/7329f194b1921649244ce26d5f33195c to your computer and use it in GitHub Desktop.
Save ThomasJunk/7329f194b1921649244ce26d5f33195c to your computer and use it in GitHub Desktop.
const pixelsPerMapMillimeter = resolution / 25.4; // resolution = resolution to print at
const mapSizeForPrint = [
Math.round(this.pdf.width * pixelsPerMapMillimeter), // 210 * resolution / DPI
Math.round(this.pdf.height * pixelsPerMapMillimeter)
];
...
const scale = 100
map.setSize(mapSizeForPrint);
const view = map.getView();
const proj = view.getProjection();
const resolutionForPrint =
(getPointResolution(proj, scale, view.getCenter()) / (10 * pixelsPerMapMillimeter)) * proj.getMetersPerUnit();
map.getView().setResolution(resolutionForPrint);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment