Skip to content

Center map on home and fit route bounds - #7

Merged
cafca merged 1 commit into
mainfrom
claude/thirsty-goodall
Apr 15, 2026
Merged

Center map on home and fit route bounds#7
cafca merged 1 commit into
mainfrom
claude/thirsty-goodall

Conversation

@cafca

@cafca cafca commented Apr 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Home centering on load: Pre-loads session and home location before mounting the map, so the map initializes at the home coordinates with no visible jump
  • Home centering on login: When a user logs in, the map instantly jumps to their home location
  • Route fit bounds: When computing a route, the map smoothly pans and zooms to fit both origin and destination in view (400ms transition, extra vertical padding for UI elements)

Details

createMap() now accepts optional center/zoom params. App.svelte awaits checkSession() + loadHomeLocation() before rendering the <Map> component, passing the home coordinates through.

For route fitting, uses LngLatBounds.extend() instead of the two-argument constructor to avoid a MapLibre bug where SW longitude > NE longitude is interpreted as antimeridian wrapping, causing the map to zoom out to show the entire globe.

Test plan

  • Load app while logged in with a home set — map should start centered on home, no flash/jump
  • Log in from anonymous — map should jump to home
  • Request a route — map should smoothly fit to show both endpoints
  • Request a short route (~50m) — should stay zoomed in (maxZoom: 15)
  • Route endpoints should not be hidden behind top/bottom UI

- Initialize map at home coordinates when logged in, avoiding a
  visible jump on page load
- Pre-load session and home location before mounting the map component
- On login/user switch, jump to the user's home location instantly
- When computing a route, fit the map to show both origin and
  destination with a short animated transition
- Use LngLatBounds.extend() to avoid antimeridian wrapping bug with
  the two-argument constructor
@cafca
cafca merged commit e1dfcf4 into main Apr 15, 2026
5 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.

1 participant