Skip to content

Add exportImage to export the map as the viewer sees it - #149

Open
aaronfraint wants to merge 1 commit into
mainfrom
aaron/export-image
Open

aaronfraint wants to merge 1 commit into
mainfrom
aaron/export-image

Conversation

@aaronfraint

Copy link
Copy Markdown

Adds felt.exportImage(), which renders the embedded map inside the embed and returns the file to the host page.

Why: the REST image export (POST /api/v2/maps/:id/image_exports) renders the saved map in a headless browser, so it can't see SDK session changes. This method runs the app's existing in-browser export inside the embed, so it includes layer visibility, ephemeral filters and layers from createLayersFromGeoJson.

Design doc: https://claude.ai/artifact/9yncpovQAMHMsQw8nCosdY

API

const { blob, filename, warnings } = await felt.exportImage({
  format: "png",          // "png" | "jpg" | "pdf" | "svg" (svg: Business plan and up)
  width: 1200, height: 800, // CSS px; defaults to the embed's map size
  pixelRatio: 2,          // 1–4
  jpgQuality: 0.9,
  viewport: { center: { latitude, longitude }, zoom }, // defaults to the current camera
  legend: { visible, showTitle, showDescription, showComponents },
  showScaleBar: true,
  download: false,        // also save the file from inside the embed
});
  • Added to the misc module: schema, controller, types, and their TSDoc (which feeds llms-full.txt).
  • Returns a Blob. Method results already travel back over a MessagePort with no JSON step, so it arrives intact.
  • download: true may be blocked by the browser in a cross-origin or sandboxed iframe. The TSDoc tells hosts to save the returned blob when they need the download to be reliable.
  • Changeset: minor.

App side

The handler, the owner opt-in permission and the setting live in the felt app. That PR needs a prerelease containing this change before it can type-check.

Checks

npm run check passes: build, format, API report, types, 21 tests, docs. The docs and etc/js-sdk.api.md were regenerated.


Generated by Claude Code

Adds felt.exportImage(), which renders the embedded map inside the
embed and returns the file to the host page. Unlike the REST image
export, it includes SDK-made session changes: layer visibility,
ephemeral filters and layers from createLayersFromGeoJson.

Supports png, jpg, pdf and svg (Business plan and up), an optional
viewport, legend switches, a scale bar, and download: true to also
save the file from inside the embed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PbCHs2dhkbaJSPke8AQvBW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants