Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlurie committed Aug 20, 2024
1 parent f4a8c7f commit 380a8bf
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/helpers/screenshot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Map as MapSDK } from "../Map";


/**
* Takes a screenshot (PNG file) of the curent map view.
* Depending on the options, this function can automatically trigger a download of te file.
Expand All @@ -25,10 +24,8 @@ export async function takeScreenshot(
* If `true`, the whole page, as displayed in browser, will be included in the screenshot.
* This requires user permission with a native prompt to select the browser tab or page.
* On Chromium-based browsers, the current tab will already be preselected.
*
* If `false`, only the map context (without DOM elements such as Markers or Popups) will be included.
* This mode does not need the user to grant permission.
*
* Default: `false`
*/
wholePage?: boolean;
Expand Down Expand Up @@ -58,13 +55,12 @@ export async function takeScreenshot(
return blob;
}


function getMapScreenshotBlob(map: MapSDK): Promise<Blob> {
return new Promise((resolve, reject) => {
map.redraw();

map.once("idle", () => {
map.getCanvas().toBlob( (blob) => {
map.getCanvas().toBlob((blob) => {
if (!blob) {
return reject(Error("Screenshot could not be created."));
}
Expand All @@ -75,7 +71,6 @@ function getMapScreenshotBlob(map: MapSDK): Promise<Blob> {
});
}


async function getPageScreenshotBlob(): Promise<Blob> {
const captureStream = await navigator.mediaDevices.getDisplayMedia({
video: {
Expand Down Expand Up @@ -112,7 +107,7 @@ async function getPageScreenshotBlob(): Promise<Blob> {
for (const track of captureStream.getTracks()) {
track.stop();
}

return new Promise((resolve, reject) => {
canvas.toBlob(async (blob) => {
if (!blob) {
Expand All @@ -122,4 +117,4 @@ async function getPageScreenshotBlob(): Promise<Blob> {
resolve(blob);
}, "image/png");
});
};
}

0 comments on commit 380a8bf

Please sign in to comment.