feat(cms-sections): add Google Maps area selector for format: map#4200
Merged
Conversation
17aee27 to
28959a1
Compare
Adds a MapField widget that renders an interactive Google Map with a draggable/resizable circle for selecting an area, mirroring the admin app's existing MapWidget. Schema string fields tagged with `format: "map"` (the convention emitted by `MapWidget` in deco-apps/admin/widgets.ts) now render the map instead of a plain text input — used by the Location matcher's `coordinates` field (includeLocations / excludeLocations) so users can pick a center + radius via the map instead of typing `"lat,lng,radius"` by hand. - New `fields/map-field.tsx`. React-19-safe (no useEffect): uses a ref-callback with a cleanup return and pins the initial value in a ref so onChange-driven re-renders don't tear down the map mid-drag. - Routes `format === "map"` to `MapField` in `schema-form.tsx`. - The Maps JS API key is a RUNTIME server env var (GOOGLE_MAPS_API_KEY), exposed to the client via /api/config (same pattern as POSTHOG_KEY) so it's configurable per environment without rebuilding. It's a client-side token by design, not a secret; security relies on Google Cloud HTTP-referrer + API restrictions. The field shows an inline "unavailable" note when the key is unset. - Adds `@types/google.maps` devDependency; the file uses a triple-slash reference instead of widening `tsconfig.json`'s `types` array. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
28959a1 to
9d1a307
Compare
decocms Bot
pushed a commit
that referenced
this pull request
Jul 2, 2026
PR: #4200 feat(cms-sections): add Google Maps area selector for `format: map` Bump type: minor - decocms (apps/mesh/package.json): 3.91.0 -> 3.92.0 Deploy-Scope: both
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MapFieldwidget that renders an interactive Google Map with a draggable/resizable circle for area selection, mirroringadmin/components/ui/Map.tsx. Schema string fields tagged withformat: "map"(the convention emitted byMapWidgetin deco-apps/admin/widgets.ts) now render the map instead of a plain text input.coordinatesfield (includeLocations/excludeLocations) so users can pick a center + radius on the map instead of typing"lat,lng,radius"by hand.Implementation notes
apps/mesh/src/web/components/sections-editor/fields/map-field.tsx. React-19-safe (nouseEffect): uses a ref-callback with a cleanup return and pins the initial value in arefsoonChange-driven re-renders don't tear down the map mid-drag.format === "map"toMapFieldinschema-form.tsx, alongside the existingimage-uri/file-uri/locationhandlers.GOOGLE_MAPS_API_KEY), exposed to the client through/api/config— the exact same pattern asPOSTHOG_KEY. Read at request time, so it's configurable per environment (dev / staging / prod) without rebuilding the bundle, and belongs in the runtime k8s config (deco-apps-cd), not the build. It's a client-side token by design — the Maps JS API loads in the browser and always ships its key in the request URL, so it can't be hidden and is not a secret; security relies on Google Cloud restrictions (HTTP-referrer allowlist + API restriction to "Maps JavaScript API"). When unset, the field renders an inline "unavailable" note instead of crashing.@types/google.mapsdevDependency; the field file uses a triple-slash reference instead of wideningtsconfig.json'stypesarray.Setup
GOOGLE_MAPS_API_KEYinapps/mesh/.env(read at server runtime).GOOGLE_MAPS_API_KEYin the runtime env (deco-apps-cd), per environment — same mechanism asDBOS_CONDUCTOR_KEY/POSTHOG_KEY. No CI/build change needed.Test plan
GOOGLE_MAPS_API_KEYset inapps/mesh/.env, thenbun run dev.lat,lng,radius.GET /api/configreturnsgoogleMapsApiKey(unit tests cover set/unset).🤖 Generated with Claude Code