Skip to content

feat: keep the map viewport in the URL so a place can be shared by link - #135

Merged
yakew7 merged 1 commit into
StudentSuite:mainfrom
aryansk:feat/viewport-deeplink
Aug 14, 2026
Merged

feat: keep the map viewport in the URL so a place can be shared by link#135
yakew7 merged 1 commit into
StudentSuite:mainfrom
aryansk:feat/viewport-deeplink

Conversation

@aryansk

@aryansk aryansk commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Problem

Closes #118. Sharing a specific place or view wasn't possible: opening /map always landed on the default view, and reloading lost the selected place and viewport.

What already existed (kept intact)

  • ?place=<id> selects the place, opens its card, and flies to it (via FlyToPlace); ?place=nonsense falls back to the default view.
  • city / types filter params round-trip through the URL.

What this PR adds

  • Viewport params: lat, lng, zoom. On load they restore that exact center/zoom instead of fitting all places.
  • URL stays in sync: a ViewportReporter inside the map mirrors pan/zoom end into the URL with history.replaceState — the acceptance criteria's "panning updates the URL but adds no browser history entries", so the back button still exits in one press.
  • Copy link reproduces the view: the map's share button and the pin popup's "Copy link" now include the viewport (pin links center on the place at zoom 15).
  • Robust parsing: lat/lng only apply when both are present and finite; a missing or bogus pair (?lat=abc) degrades to the default view without crashing.

Verification

  • 42 unit tests pass (11 in share.test.ts, including viewport round-trips, zoom-omission, and malformed-param handling).
  • tsc --noEmit, eslint, and next build clean.
  • next start smoke test: /map, /map?lat=19.076&lng=72.8777&zoom=12, /map?place=mum-library-01, /map?place=nonsense, and /map?lat=abc&lng=72.8777 all return 200 with no server errors.

Extends the existing share state (place/city/types, already selected and centred via ?place=) with lat/lng/zoom viewport params: parseMapState restores them on load (skipping the fit-all view), a ViewportReporter mirrors pan/zoom into the URL with replaceState (no history entries), and copy-link now reproduces the exact viewport in a fresh tab. Invalid viewport params degrade to the default view instead of crashing.

Closes StudentSuite#118
@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

@AryanSingh is attempting to deploy a commit to the studentsuite Team on Vercel.

A member of the Team first needs to authorize it.

@yakew7
yakew7 marked this pull request as ready for review August 14, 2026 15:14
@yakew7
yakew7 merged commit c594361 into StudentSuite:main Aug 14, 2026
3 of 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.

Make map state deep-linkable so a place can be shared by URL

3 participants