Skip to content

feat: rotate the exported map by a bearing - #34

Merged
gmaclennan merged 1 commit into
mainfrom
feat/rotation
Sep 17, 2026
Merged

gmaclennan merged 1 commit into
mainfrom
feat/rotation

Conversation

@gmaclennan

Copy link
Copy Markdown
Member

Adds a rotation setting so north need not be at the top of the print.
Tiles were already screen-space rects rendered as small MapLibre maps, and
MapLibre turns rigidly about the screen centre, so a bearing only changes
how a screen offset becomes a world point: tileGrid and the renderer's
edge-tile alignment turn their offsets by the bearing, and everything after
the renderer is untouched. The bbox is fitted north-up as before and the
page turns about its centre.

The hidden renderer map now passes a no-op transformConstrain: MapLibre's
default pans a camera whose unrotated frame crosses the latitude limit,
which would misalign an edge tile of a rotated page. fitsWorld checks all
four page corners instead. Raster layers can jog by up to a device pixel at
seams of a rotated page because MapLibre snaps them to whole world pixels
per map; this is documented rather than fixed.

The form gains a Rotation field, the preview map drag-rotates with a
compass and the two stay in sync, and the preview draws the page outline
alongside the bbox since the bbox corners can fall off a rotated page. The
e2e pages use a taller viewport so the longer form needs no scrolling,
which WebKit's checkbox click did not survive.

Closes #5


Stack created with GitHub Stacks CLI • Give Feedback 💬

Adds a rotation setting so north need not be at the top of the print.
Tiles were already screen-space rects rendered as small MapLibre maps, and
MapLibre turns rigidly about the screen centre, so a bearing only changes
how a screen offset becomes a world point: tileGrid and the renderer's
edge-tile alignment turn their offsets by the bearing, and everything after
the renderer is untouched. The bbox is fitted north-up as before and the
page turns about its centre.

The hidden renderer map now passes a no-op transformConstrain: MapLibre's
default pans a camera whose unrotated frame crosses the latitude limit,
which would misalign an edge tile of a rotated page. fitsWorld checks all
four page corners instead. Raster layers can jog by up to a device pixel at
seams of a rotated page because MapLibre snaps them to whole world pixels
per map; this is documented rather than fixed.

The form gains a Rotation field, the preview map drag-rotates with a
compass and the two stay in sync, and the preview draws the page outline
alongside the bbox since the bbox corners can fall off a rotated page. The
e2e pages use a taller viewport so the longer form needs no scrolling,
which WebKit's checkbox click did not survive.

Closes #5
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
map-printer 7b90257 Commit Preview URL

Branch Preview URL
Sep 17 2026, 02:24 PM

@gmaclennan
gmaclennan merged commit 5f4528d into main Sep 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Orientation Control

1 participant