Skip to content

Phone app: Google map tiles when a key is available - #13

Merged
Torgh merged 1 commit into
mobile-mapfrom
mobile-google-tiles
Oct 18, 2026
Merged

Torgh merged 1 commit into
mobile-mapfrom
mobile-google-tiles

Conversation

@Torgh

@Torgh Torgh commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Summary

Builds on #12 (the phone app's day map); merge that first. This PR only changes the map underneath the pins.

  • Google tiles when there's a key. If the APK is built with NEXT_PUBLIC_GOOGLE_MAPS_API_KEY in .env.local (the desktop app's browser key, with the Map Tiles API enabled), the phone map draws Google's tiles through the official Map Tiles API. MapLibre stays, so pins, routes, tour stops, full screen and the pin ↔ card link are unchanged.
  • Fallbacks: no key, or Google can't be reached (quota, network) → OpenFreeMap; no network → plain background with pins and routes from the trip file.
  • The Map Tiles session is reused for its lifetime (about two weeks) instead of opened per map; dark mode gets a dark Google look.
  • Google's logo and the copyright for the area in view are shown, as Google's terms require.

Keeping the key out of the repo

  • The source never contains a key: mobile/vite.config.mts exposes only that one variable from .env.local (gitignored) to the build.
  • Builds without the variable, like CI, use OpenFreeMap.
  • README and .env.example warn that the key ends up inside such an APK, so it shouldn't be shared or published.
  • Verified before pushing: the staged diff and the pushed commits contain no key.

Note for offline maps (next step)

Google's terms don't allow storing tiles for later, so downloading maps for offline use will keep using OpenFreeMap.

Test plan

  • bun run typecheck, eslint, bun run test:coverage (194 tests), bun run build:mobile
  • Phone UI in Chrome at phone size, Mexico trip, day 8: with the key, Google tiles with the Google logo and "©2026 Google, INEGI"; pins, tour stops and route on top
  • Same day with the variable empty: OpenFreeMap with its OpenStreetMap credit
  • Google tiles on a real phone

🤖 Generated with Claude Code

The phone map now draws Google's tiles (Map Tiles API) when the APK is built
with NEXT_PUBLIC_GOOGLE_MAPS_API_KEY in .env.local, the desktop app's browser
key. Without it, or when Google can't be reached, it falls back to OpenFreeMap,
and offline to the plain background with pins and routes.

The Map Tiles session is reused for its lifetime, dark mode gets a dark Google
look, and the map shows Google's logo with the copyright for the area in view.
Only that one variable is exposed to the build; the source never contains a
key. README and .env.example say the key ends up inside such an APK, so it
should not be shared.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Torgh
Torgh merged commit f793bc7 into mobile-map Oct 18, 2026
2 checks passed
Torgh added a commit that referenced this pull request Oct 18, 2026
* Show the day's map and route in the phone app

A map band sits above the day's plan and stays put while the list scrolls, so
dragging the map never fights the page. It can be hidden (remembered) or opened
full screen; Android back closes full screen first. Tapping a pin scrolls to
its card; tapping a card brings its pin into view. In full screen a tapped pin
shows what it is (a tour stop names itself and its tour) with a way back to
the plan.

Pins, route lines and tour stops come from lib/mapLayers.ts, now shared with
the desktop map, so both draw the same thing. Route shapes are read from the
trip file; without network the map falls back to a plain background, keeping
pins and routes readable offline. MapLibre loads only once a trip is opened.

The morning's hotel pin is left out when a card sits at the same spot (a tour
picking you up at the hotel), where it hid that card's numbered pin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Use Google's map tiles in the phone app when a key is available (#13)

The phone map now draws Google's tiles (Map Tiles API) when the APK is built
with NEXT_PUBLIC_GOOGLE_MAPS_API_KEY in .env.local, the desktop app's browser
key. Without it, or when Google can't be reached, it falls back to OpenFreeMap,
and offline to the plain background with pins and routes.

The Map Tiles session is reused for its lifetime, dark mode gets a dark Google
look, and the map shows Google's logo with the copyright for the area in view.
Only that one variable is exposed to the build; the source never contains a
key. README and .env.example say the key ends up inside such an APK, so it
should not be shared.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@Torgh
Torgh deleted the mobile-google-tiles branch October 20, 2026 19:26
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