Skip to content

Commit 9c24d1e

Browse files
fix(notebook): enable map to show in pdf/png download (#3963)
* feat: enable map background to show up in download pdf/png * fix: enable download map in pdf/png * chore: add comment on canvas option
1 parent 63eb821 commit 9c24d1e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/flows/components/header/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ const FlowHeader: FC = () => {
204204
.querySelectorAll('[data-download-hide]')
205205
.forEach(d => (d.style.display = 'block'))
206206
},
207+
// Enable map background
208+
useCORS: true,
207209
}
208210

209211
const handleDownloadAsPNG = () => {

src/flows/pipes/Visualization/view.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,15 @@ import {downloadImage} from 'src/shared/utils/download'
3535
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
3636
import ErrorBoundary from 'src/shared/components/ErrorBoundary'
3737

38+
// Enable map background
39+
const canvasOption = {
40+
useCORS: true,
41+
}
42+
3843
const downloadAsImage = (pipeID: string) => {
3944
const canvas = document.getElementById(pipeID)
4045
import('html2canvas').then((module: any) =>
41-
module.default(canvas as HTMLDivElement).then(result => {
46+
module.default(canvas as HTMLDivElement, canvasOption).then(result => {
4247
downloadImage(result.toDataURL(), 'visualization.png')
4348
})
4449
)
@@ -47,7 +52,7 @@ const downloadAsImage = (pipeID: string) => {
4752
const downloadAsPDF = (pipeID: string) => {
4853
const canvas = document.getElementById(pipeID)
4954
import('html2canvas').then((module: any) =>
50-
module.default(canvas as HTMLDivElement).then(result => {
55+
module.default(canvas as HTMLDivElement, canvasOption).then(result => {
5156
import('jspdf').then((jsPDF: any) => {
5257
const doc = new jsPDF.default({
5358
orientation: 'l',

0 commit comments

Comments
 (0)