Skip to content

fix(map): cap the search zoom and open on the visitor's last or home view - #360

Merged
yakew7 merged 1 commit into
mainfrom
fix/map-start-view-and-zoom-cap
Nov 24, 2026
Merged

yakew7 merged 1 commit into
mainfrom
fix/map-start-view-and-zoom-cap

Conversation

@propcgamer20-png

Copy link
Copy Markdown
Member

What this changes

Two map start-view bugs that share the same code.

#353, search zoomed to level 19. ?q=esenboga leaves one place, and FitAllOnMount fitted a zero-size box around it with no cap, so Leaflet fell back to its maximum zoom, where the basemap is blank. The fit is now capped at zoom 16 for one place and 15 for several. FlyToPlace uses the same shared constant, so search, list click and ?place= follow one rule.

#350, world view with grey bands.

  • A minimum zoom is computed from the container size, so the tiles always cover the viewport (it follows resizes).
  • The map reopens where the visitor last left it (localStorage, every read and write in try/catch).
  • If nothing chose a start view, a signed-in visitor's saved home is used.
  • An explicit ?lat&lng&zoom, ?place=, search or filter in the URL still wins over all of the above. Nothing triggers a geolocation prompt on load.

The shared rules live in src/components/map/viewport.ts (no Leaflet or React in it) with their own tests.

Type of change

  • Code or fix

Testing

  • npm run typecheck, npm run lint, npm run test:unit all pass locally.
  • New tests: the zoom cap for one and several places, the minimum zoom call, opening on home only when nothing else chose a view, and ignoring home when a viewport was restored; unit tests for the stored-viewport parser (malformed, out-of-range and blocked storage).

Not covered

  • The "country from onboarding" step in the Map opens on a zoomed-out world view with grey bands and 2,016 unfiltered places #350 proposal is not included: the profile is not loaded on /map today, and loading it is a separate change. The acceptance list does not require it.
  • I checked behaviour through the unit tests, not by eye in a browser (no MapTiler key on my machine), so a visual check of the grey bands at 1366x768 and a phone size would be worth doing on the preview.
  • No changelog line, to avoid conflicts with the other open PRs touching the same section; happy to add one.

Closes #350
Closes #353

…view

A search that leaves one place fitted a zero-size box and zoomed to level
19, where the basemap is blank. The fit is now capped (16 for one place,
15 for several) and the go-to-place zoom shares one constant.

The map used to open on the whole world with grey bands above and below
the tiles. It now keeps the basemap covering the viewport with a minimum
zoom, reopens where the visitor last left it (localStorage, guarded), and
opens on a signed-in visitor's saved home when nothing else chose a view.
An explicit lat/lng/zoom, place, search or filter in the URL still wins,
and nothing asks for geolocation on load.

Closes #350
Closes #353
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
study-map Ready Ready Preview Nov 24, 2026 9:15am UTC

@yakew7
yakew7 merged commit 220b919 into main Nov 24, 2026
6 checks passed

This branch was successfully deployed

1 active deployment
Preview — 93b9f3f2 Deployed Nov 24, 2026 by vercel[bot]
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.

Searching for one place zooms to level 19, where the tiles are blank Map opens on a zoomed-out world view with grey bands and 2,016 unfiltered places

2 participants