← All @molecule/* packages · App templates
@molecule/api-geolocation-googleProvider bond · geolocation · API (Node) · v1.0.1 · Apache-2.0
Google Maps geolocation provider for molecule.dev
npm install @molecule/api-geolocation-googlenpm · Source on GitHub · Implements @molecule/api-geolocation
@molecule/api-geolocation-google is a provider bond on the API (Node) side: it implements the geolocation core interface (@molecule/api-geolocation) with a concrete vendor or library behind it.
Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.
import { setProvider } from '@molecule/api-geolocation'
import { provider } from '@molecule/api-geolocation-google'
setProvider(provider)Works with: @molecule/api-geolocation, @molecule/api-secrets
Secrets: GOOGLE_MAPS_API_KEY
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Google Maps geolocation provider for molecule.dev.
Implements the GeolocationProvider interface using Google Maps Geocoding,
Places Autocomplete, and Timezone APIs. Supports geocoding, reverse geocoding,
Haversine distance calculations, place autocomplete, and timezone lookups.
import { setProvider } from '@molecule/api-geolocation'
import { provider } from '@molecule/api-geolocation-google'
setProvider(provider)
provider
npm install @molecule/api-geolocation-google @molecule/api-geolocation @molecule/api-secrets
GoogleGeolocationConfigConfiguration options for the Google Maps geolocation provider.
interface GoogleGeolocationConfig {
/** Google Maps API key. Required. */
apiKey: string
/** BCP 47 language code for results (e.g., `'en'`, `'fr'`). */
language?: string
/** ISO 3166-1 alpha-2 region code to bias results (e.g., `'US'`). */
region?: string
/** Request timeout in milliseconds. Defaults to `10000`. */
timeout?: number
/** Base URL override for proxied or self-hosted services. Defaults to `'https://maps.googleapis.com'`. */
baseUrl?: string
}
createProvider(config)Creates a Google Maps geolocation provider.
function createProvider(config: GoogleGeolocationConfig): GeolocationProvider
config — Provider configuration including the Google Maps API key.Returns: A GeolocationProvider backed by Google Maps APIs.
geolocationGoogleSecretDefinitionsSecret definitions required by the Google geolocation bond.
const geolocationGoogleSecretDefinitions: SecretDefinition[]
providerThe provider implementation, lazily initialized with API key from
GOOGLE_MAPS_API_KEY and an optional base URL override from
GOOGLE_MAPS_BASE_URL (for proxying through a credential broker or a
self-hosted/compatible service).
const provider: GeolocationProvider
Implements @molecule/api-geolocation interface.
Setup function to register this provider with the core interface:
import { setProvider } from '@molecule/api-geolocation'
import { provider } from '@molecule/api-geolocation-google'
export function setupGeolocationGoogle(): void {
setProvider(provider)
}
Peer dependencies:
@molecule/api-geolocation ^1.0.1@molecule/api-secrets ^1.0.1GOOGLE_MAPS_API_KEY (required) — Google Maps API key
AIza...@molecule/api-geolocation@molecule/api-secretsIntegration checklist — drive the real UI (live preview, no mocks), adapt each item to this app's actual screens/flows, and check every box off one by one. A box you can't check is an integration bug to fix — not a skip:
geocode() returns coordinates in roughly the right place (a
famous landmark lands inside its own city, not the middle of the ocean),
and a known lat/lng passed to reverseGeocode() names the right city —
never an empty array, null, 0,0, or a hardcoded placeholder.distance() (closest first), or the address form marks a real
address valid and a bogus one invalid — a coordinate that comes back but
changes nothing in the UI is a broken integration, not a pass.geocode()/
reverseGeocode() result) surfaces a clear "location not found" message,
not a crash, a silent blank screen, or a default location shown as if real.