Skip to content

Commit

Permalink
small fixes (code review)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniave committed Jun 17, 2024
1 parent 143304d commit f0086b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/packages/printing/Printing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { PackageIntl } from "@open-pioneer/runtime";
import { useIntl, useService } from "open-pioneer:react-hooks";
import { FC, useEffect, useState } from "react";
import { FileFormatType, PrintingController } from "./PrintingController";
import { ViewPaddingBehavior, type PrintingService } from "./index";
import type { ViewPaddingBehavior, PrintingService } from "./index";

const LOG = createLogger("printing");

Expand All @@ -31,7 +31,7 @@ export interface PrintingProps extends CommonComponentProps {
mapId: string;

/**
* Whether to respect the map's padding when printing (default: `"auto"`).
* Whether to respect the map view's padding when printing (default: `"auto"`).
*
* See also {@link ViewPaddingBehavior}.
*/
Expand Down
7 changes: 3 additions & 4 deletions src/packages/printing/PrintingServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export class PrintJob {
}

// Position the scale bar manually.
// The 50px should be plenty to avoid overlapping with openlayers attributions on most cases.
// Additionally take the view padding into account (if behavior is 'auto').
// The 50px should be plenty to avoid overlapping with open layers attributions on most cases.
// Additionally, take the view padding into account (if behavior is 'auto').
let bottom = 50;
let left = 8;
if (this.viewPadding === "auto") {
Expand Down Expand Up @@ -220,9 +220,8 @@ export class PrintJob {
newCanvas.width = width - padding.left - padding.right;
newCanvas.height = height - padding.top - padding.bottom;

const ctx = canvas.getContext("2d");
const newCtx = newCanvas.getContext("2d");
if (!ctx || !newCtx) {
if (!newCtx) {
throw new Error("Failed to get a canvas context");
}

Expand Down
4 changes: 2 additions & 2 deletions src/packages/printing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export interface PrintingOptions {
overlayText?: string;

/**
* Whether to respect the map's padding when printing (default: `"auto"`).
* Whether to respect the map view's padding when printing (default: `"auto"`).
*/
viewPadding?: ViewPaddingBehavior;
}

/**
* Whether to respect the map's padding when printing.
* Whether to respect the map view's padding when printing.
*
* - `"auto"`: Respect the map's current viewPadding.
* Padded regions of the map will _not_ be included in the print result.
Expand Down

0 comments on commit f0086b2

Please sign in to comment.