Project
Crumb & Compass: a custom map that looks like the brand
A styled Google Map for a made-up Toronto bakery chain, with custom pins, pop-ups and a keyboard-friendly list of every location. The pins live in Sanity, so adding a bakery is a content edit, not a code change.
- My role
- Solo build
- Stack
- astro
- react
- typescript
- sanity
- google maps
- tailwind

Why I built it
I’ve built custom maps for a few client sites, but none of them are mine to show. I wanted one I could actually point people to.
I also just think maps are visually pleasing. Before I go on vacation, I always make a custom map with all the spots I want to hit up. There’s something comforting about being able to orient yourself visually.
So here’s one you can play with. Crumb & Compass is a made-up bakery chain with eight Toronto locations. Click a pin, or pick a bakery from the list.
Crumb & Compass locations
My other map project, LootRoute, is about getting from A to B. This one is about making the map itself worth looking at.
How it works
Explain it like I’m five
Sanity is the address book and Google draws the map. When the site builds, it reads every bakery out of the address book and puts a pin on the map for each one. Adding a bakery is a content edit, not a code change.
- Each location is its own document in Sanity: a name, a cross street, coordinates (Sanity’s built-in
geopointfield), a specialty and opening hours. - The site fetches the locations at build time and hands them to a small React component (an island), so the browser never talks to the CMS.
- The map itself uses
@vis.gl/react-google-maps, the React library Google’s own samples use. Pins are Advanced Markers with custom HTML, so they can look like anything. - The colours come from this site’s palette, but they don’t live in the code. They’re a map style in Google Cloud, attached to a Map ID.
The interesting bits
The styling lives in Google Cloud now
Older Google Maps were styled with a big block of JSON in your code. The newer way is cloud-based styling: you design the style in the Google Cloud console and point the map at it with a Map ID. Advanced Markers need a Map ID, so new maps end up here anyway.
Map ID and JSON styles don’t mix
Once a map has a Map ID, any JSON styles in your code are ignored. If you’re moving an older map to Advanced Markers and the styling suddenly disappears, that’s why. Rebuild the style in the Cloud console instead.
The style has a light and a dark version, and the map follows this site’s theme toggle. The map’s colour scheme can only be set when it’s created, so switching themes quietly rebuilds it.
The list isn’t an afterthought
Maps are hard to use with a keyboard or a screen reader. So every location is also a button in a plain list under the map, and picking one in either place selects it in both. The pins are focusable too, with the bakery name as their label.
The map also uses cooperative gestures: scrolling the page scrolls the page. To zoom, hold Ctrl while you scroll, or use two fingers on a phone. Nothing is more annoying than a map that hijacks your scroll halfway down a page.
A map that broke JavaScript’s Map
The React library exports a component called Map. JavaScript already has a built-in Map, and importing the component under that name replaces it for the whole file. Any new Map() in that file then tries to create a Google map instead. Renaming the import avoids it:
// Not `Map`: that would shadow JavaScript's built-in Map in this file.
import {Map as GoogleMap} from '@vis.gl/react-google-maps'The key is public, and that’s okay
A Google Maps key always ends up in the browser. That’s just how the Maps JavaScript API works, so the protection comes from restricting what the key can do:
- Website restrictions: the key only works on this site’s domain (and localhost for testing).
- API restrictions: it can only load the Maps JavaScript API, nothing else on the account.
Google gives each Maps product a free monthly allowance, which for this kind of map is 10,000 map loads. A portfolio page won’t come close.
The error that always gets us
BillingNotEnabledMapError, or the grey “This page can’t load Google Maps correctly” box. It’s usually not your code at all: it’s an expired credit card on the Google Cloud billing account. Check Billing in the Cloud console before you start debugging.
What I’d tell past me
Get comfortable working in the Google Cloud console. There’s a lot to learn and get familiar with there.
