Use this reference to find verified sample code by Google Maps Platform API, verify REST header & CORS requirements, fix common runtime errors, or migrate off deprecated APIs.
- Back to:
AGENTS.md|BY_FRAMEWORK.md|README.md|catalog.json
- REST API Transport & Header Matrix (CORS vs. Server BFF)
- JS SDK vs. REST Field Naming Cheatsheet
- Common GMP Runtime Errors -> Verified Fix
- Samples by API & Geo Library
- Legacy-to-Modern Migration Guide
| GMP REST Service | Browser CORS? | Auth & X-Goog-FieldMask Rule |
Real-Code Gotcha | Reference Sample(s) |
|---|---|---|---|---|
Places API (New) (places.googleapis.com/v1/places:*) |
❌ Blocked | POST, X-Goog-Api-Key + mandatory X-Goog-FieldMask |
Photo media (/{name}/media) streams binary bytes (X-Goog-Api-Key, no FieldMask). On pure client stacks use JS Place.*. |
storefront-sample, neighborhood-discovery |
Routes API v2 (routes.googleapis.com/directions/v2:*, distanceMatrix/v2:*) |
❌ Blocked | POST, X-Goog-Api-Key + mandatory X-Goog-FieldMask |
Matrix returns a top-level JSON array; only set routingPreference: 'TRAFFIC_AWARE' when travelMode === 'DRIVE'; cap TRANSIT to 25 destinations. |
store-locator, ridesharing-and-tracker |
Roads API (roads.googleapis.com/v1/snapToRoads) |
❌ Blocked | GET ?path=lat,lng|...&interpolate=true&key= — NO X-Goog-FieldMask |
Hard limit of 2..100 GPS points per request; never send X-Goog-FieldMask. |
logistics-and-routing |
Address Validation API (addressvalidation.googleapis.com/v1:validateAddress) |
❌ Blocked | POST, X-Goog-Api-Key (no required FieldMask) OR JS SDK importLibrary('addressValidation') |
JS SDK uses uspsCASSEnabled; REST uses enableUspsCass. Only read weekly-safe verdict fields. |
live-order-tracking |
Geocoding API (geocode.googleapis.com/v4/... & maps/api/geocode/json) |
❌ Blocked | v4: X-Goog-Api-Key; v3: GET ?key= (NO X-Goog-FieldMask); Client: JS Geocoder |
driving-and-geofencing demonstrates Geocoding v4 BFF; other BFFs use v3 or JS Geocoder. |
driving-and-geofencing, neighborhood-discovery |
Elevation API (maps.googleapis.com/maps/api/elevation/json) |
❌ Blocked | GET ?path=...&samples=...&key= — NO X-Goog-FieldMask; Client: JS ElevationService |
Never pass X-Goog-FieldMask to legacy Elevation REST. |
3d-trail-explorer, travel-route-comparator |
Weather / Pollen / Solar APIs (weather/pollen/solar.googleapis.com/v1/...) |
✅ OK (?key=) |
GET ?location.latitude=...&key= (or BFF proxy) — no required FieldMask |
Solar buildingInsights:findClosest returns HTTP 404 outside building coverage (use requiredQuality=MEDIUM and render a graceful non-coverage state). |
environmental-dashboard, complete-heatmap |
Air Quality API (airquality.googleapis.com/v1/...) |
✅ OK (?key=) |
POST ?key= (JSON) & GET .../heatmapTiles/{z}/{x}/{y}?key= (binary PNG — NO X-Goog-FieldMask) |
AQI color RGB components are floats 0..1 (multiply by 255 for CSS); clamp tile zoom 0..16 and wrap x in ImageMapType. |
environmental-dashboard |
Maps Static API (maps.googleapis.com/maps/api/staticmap) |
✅ <img> |
BFF binary PNG proxy recommended to hide key (or <img> URL) — NO X-Goog-FieldMask |
Cap enc: polyline strings to <= 1600 chars (fall back to straight line) to avoid URL length errors. |
live-order-tracking |
Time Zone API (maps.googleapis.com/maps/api/timezone/json) |
GET ?location=lat,lng×tamp=...&key= — NO X-Goog-FieldMask |
Proxy via BFF/Vite middleware for key protection and consistent CORS behavior. | itinerary-planner |
| Concept | Maps JS SDK (Client) | GMP REST API (Server BFF) |
|---|---|---|
| Google Maps URL | place.googleMapsURI (uppercase URI) |
places.googleMapsUri (camelCase) |
| Route duration | route.durationMillis (number) |
routes.duration ("123s" proto string) |
| Travel mode | 'DRIVING', 'WALKING', 'BICYCLING', 'TRANSIT' |
'DRIVE', 'WALK', 'BICYCLE', 'TRANSIT' |
| Optimized waypoints | optimizedIntermediateWaypointIndices (plural) |
routes.optimizedIntermediateWaypointIndex (singular) |
| USPS CASS flag | uspsCASSEnabled: true |
enableUspsCass: true |
| Marker click event | 2D AdvancedMarkerElement: 'click' (weekly) |
3D Marker3DInteractiveElement: 'gmp-click' |
| Error Message / Symptom | Root Cause & Verified Fix | Reference Sample |
|---|---|---|
google.maps.Marker is not available to new customers |
Use AdvancedMarkerElement (importLibrary('marker')) with mapId: 'DEMO_MAP_ID'. |
storefront-sample |
gmp-placeselect listener never fires |
Retired alpha event — listen to gmp-select and call event.placePrediction.toPlace().fetchFields(...). |
storefront-sample/react-vite |
Place.prototype.isOpen() is not available in this version |
isOpen() is beta-only; on weekly channel inspect regularOpeningHours.periods / weekdayDescriptions. |
storefront-sample |
The map is initialized without a valid Map ID |
Pass mapId: 'DEMO_MAP_ID' (prototyping) or your Cloud Map ID on 2D maps. (Do NOT pass mapId to <gmp-map-3d>.) |
store-locator |
blocked by CORS policy calling places/routes/roads/addressvalidation |
Use Maps JS importLibrary(...) on client OR route through a server /api/* BFF endpoint. |
store-locator/nextjs |
400 INVALID_ARGUMENT on Places/Routes REST |
Missing X-Goog-FieldMask, OR passing routingPreference: 'TRAFFIC_AWARE' on WALK/TRANSIT mode. |
store-locator/nextjs |
403 API_KEY_HTTP_REFERRER_BLOCKED from server BFF |
Use a separate IP-restricted GOOGLE_MAPS_API_KEY on the server, or forward a validated Referer when sharing a client key. |
live-order-tracking/sveltekit |
TypeError: Loader is not a constructor |
@googlemaps/js-api-loader v2 removed new Loader() — use setOptions({ key, v: 'weekly' }) + importLibrary(...). |
vue-vite |
MarkerClusterer renders legacy red pins / deprecation error |
Default cluster renderer uses deprecated Marker — pass a custom renderer.render returning AdvancedMarkerElement. |
store-locator/nextjs |
| Terra Draw polygons don't render or fail on load | Init TerraDrawGoogleMapsAdapter inside google.maps.event.addListenerOnce(map, 'idle', ...) with isolatedData: true, wait for draw.on('ready'), filter !feature.properties.currentlyDrawing, reverse [lng,lat]->{lat,lng}. |
driving-and-geofencing/angular |
<gmp-map-3d> renders 0x0 or throws on flyCameraTo |
Set CSS display: block + explicit height, omit mapId, await customElements.whenDefined('gmp-map-3d'), keep instance non-reactive. |
3d-trail-explorer/vue-vite |
Solar API returns HTTP 404 |
Normal for coordinates outside high-res rooftop coverage — pass requiredQuality=MEDIUM and render a non-coverage state. |
environmental-dashboard |
- Modern APIs / Symbols:
Map (mapId),AdvancedMarkerElement,PinElement (glyphText / glyphSrc),InfoWindow,Polygon,Polyline,Circle - Transport: Browser JS SDK (
importLibrary('maps')/importLibrary('marker')) (Maps Demo Key OK) - Official Docs: Maps JS 2D Documentation
- Verified Samples (15):
3d-trail-explorer,complete-heatmap,driving-and-geofencing,environmental-dashboard,ev-charging-map-and-dispatch,itinerary-planner,live-order-tracking,logistics-and-routing,neighborhood-discovery,real-estate,ridesharing-and-tracker,spatial-intelligence,store-locator,storefront-sample,travel-route-comparator
- Modern APIs / Symbols:
Map3DElement (),Polyline3DElement,Marker3DInteractiveElement,PopoverElement,flyCameraTo() - Transport: Browser JS SDK (
importLibrary('maps3d')or@vis.gl/react-google-maps/3d) (Maps Demo Key OK) - Official Docs: Photorealistic 3D Documentation
- Verified Samples (1):
3d-trail-explorer
- Modern APIs / Symbols:
PlaceAutocompleteElement (gmp-select),Place.searchByText(),Place.searchNearby(),Place.fetchFields(),AutocompleteSuggestion - Transport: JS SDK (
importLibrary('places')) OR Server BFFPOST places.googleapis.com/v1/places:*(X-Goog-Api-Key+ mandatoryX-Goog-FieldMask) (Maps Demo Key OK) - Official Docs: Places (New) Documentation
- Verified Samples (15):
3d-trail-explorer,complete-heatmap,driving-and-geofencing,environmental-dashboard,ev-charging-map-and-dispatch,itinerary-planner,live-order-tracking,logistics-and-routing,neighborhood-discovery,real-estate,ridesharing-and-tracker,spatial-intelligence,store-locator,storefront-sample,travel-route-comparator
- Modern APIs / Symbols:
Route.computeRoutes(),RouteMatrix.computeRouteMatrix(),optimizeWaypointOrder,FUEL_EFFICIENT / FUEL_CONSUMPTION - Transport: JS SDK (
importLibrary('routes')) OR Server BFFPOST routes.googleapis.com/directions/v2:computeRoutes/distanceMatrix/v2:computeRouteMatrix(X-Goog-Api-Key+ mandatoryX-Goog-FieldMask) (Maps Demo Key OK) - Official Docs: Routes API Documentation
- Verified Samples (11):
complete-heatmap,driving-and-geofencing,ev-charging-map-and-dispatch,itinerary-planner,live-order-tracking,logistics-and-routing,real-estate,ridesharing-and-tracker,store-locator,storefront-sample,travel-route-comparator
- Modern APIs / Symbols:
requestedReferenceRoutes: ['FUEL_EFFICIENT'],extraComputations: ['FUEL_CONSUMPTION'],routeLabels: ['FUEL_EFFICIENT'] - Transport: JS SDK (
Route.computeRoutes) OR Server BFF (routes.googleapis.com/directions/v2:computeRouteswithX-Goog-FieldMask) (Maps Demo Key OK) - Official Docs: Eco-Routing Documentation
- Verified Samples (2):
ridesharing-and-tracker,travel-route-comparator
- Modern APIs / Symbols:
RouteMatrix.computeRouteMatrix(),distanceMatrix/v2:computeRouteMatrix - Transport: JS SDK (
importLibrary('routes')) OR Server BFF (POSTreturning top-level JSON array;TRAFFIC_AWAREonly forDRIVE; max 25 dests forTRANSIT) (Maps Demo Key OK) - Official Docs: Route Matrix Documentation
- Verified Samples (5):
ev-charging-map-and-dispatch,logistics-and-routing,real-estate,ridesharing-and-tracker,store-locator
- Modern APIs / Symbols:
Geocoder (importLibrary('geocoding')),geocode.googleapis.com/v4/geocode/location/{lat},{lng},maps.googleapis.com/maps/api/geocode/json - Transport: JS SDK (
Geocoder) OR Server BFF (Geocoding v4 withX-Goog-Api-Keyor legacy v3GET ?key=, NOX-Goog-FieldMask) (Maps Demo Key OK) - Official Docs: Geocoding Documentation
- Verified Samples (8):
complete-heatmap,driving-and-geofencing,environmental-dashboard,ev-charging-map-and-dispatch,live-order-tracking,neighborhood-discovery,real-estate,store-locator
- Modern APIs / Symbols:
StreetViewService.getPanorama(),StreetViewPanorama - Transport: Browser JS SDK (
importLibrary('streetView')) (Maps Demo Key OK) - Official Docs: Street View Documentation
- Verified Samples (3):
itinerary-planner,real-estate,storefront-sample
- Modern APIs / Symbols:
ElevationService.getElevationAlongPath(),ElevationService.getElevationForLocations(),maps.googleapis.com/maps/api/elevation/json - Transport: JS SDK (
importLibrary('elevation')) OR Server BFFGET ?path=...&samples=...&key=(NOX-Goog-FieldMask) (Requires Cloud Billing Key) - Official Docs: Elevation Documentation
- Verified Samples (4):
3d-trail-explorer,complete-heatmap,spatial-intelligence,travel-route-comparator
- Modern APIs / Symbols:
AddressValidation.fetchAddressValidation(),addressvalidation.googleapis.com/v1:validateAddress - Transport: Server BFF
POST addressvalidation.googleapis.com/v1:validateAddress(X-Goog-Api-Key, NO requiredX-Goog-FieldMask) OR JS SDKimportLibrary('addressValidation')(Requires Cloud Billing Key) - Official Docs: Address Validation Documentation
- Verified Samples (1):
live-order-tracking
- Modern APIs / Symbols:
roads.googleapis.com/v1/snapToRoads - Transport: Server/Proxy
GET ?path=lat,lng|...&interpolate=true&key=(CORS-blocked in browser, max 100 pts, NOX-Goog-FieldMask) (Requires Cloud Billing Key) - Official Docs: Roads API Documentation
- Verified Samples (1):
logistics-and-routing
- Modern APIs / Symbols:
maps.googleapis.com/maps/api/timezone/json - Transport: Server/Proxy OR Browser CORS
GET ?location=lat,lng×tamp=...&key=(NOX-Goog-FieldMask) (Requires Cloud Billing Key) - Official Docs: Time Zone Documentation
- Verified Samples (1):
itinerary-planner
- Modern APIs / Symbols:
maps.googleapis.com/maps/api/staticmap - Transport: Server BFF binary PNG proxy (recommended to hide API key; cap
enc:polyline<= 1600chars) OR direct<img>URL (Requires Cloud Billing Key) - Official Docs: Maps Static Documentation
- Verified Samples (1):
live-order-tracking
- Modern APIs / Symbols:
weather.googleapis.com/v1/currentConditions:lookup,weather.googleapis.com/v1/forecast/days:lookup - Transport: Browser CORS
GET ?location.latitude=...&key=OR Server BFF proxy (NO requiredX-Goog-FieldMask) (Maps Demo Key OK) - Official Docs: Weather API Documentation
- Verified Samples (2):
complete-heatmap,environmental-dashboard
- Modern APIs / Symbols:
airquality.googleapis.com/v1/currentConditions:lookup,airquality.googleapis.com/v1/mapTypes/US_AQI/heatmapTiles/{z}/{x}/{y},ImageMapType - Transport: Browser CORS (
POST ?key=+ImageMapTypePNG tiles) OR Server BFF proxy (binary PNG tiles use NOX-Goog-FieldMask) (Requires Cloud Billing Key) - Official Docs: Air Quality Documentation
- Verified Samples (1):
environmental-dashboard
- Modern APIs / Symbols:
pollen.googleapis.com/v1/forecast:lookup - Transport: Browser CORS
GET ?location.latitude=...&key=OR Server BFF proxy (NO requiredX-Goog-FieldMask) (Requires Cloud Billing Key) - Official Docs: Pollen API Documentation
- Verified Samples (1):
environmental-dashboard
- Modern APIs / Symbols:
solar.googleapis.com/v1/buildingInsights:findClosest - Transport: Browser CORS
GET ?location.latitude=...&requiredQuality=MEDIUM&key=OR Server BFF proxy (handle HTTP 404 non-coverage cleanly) (Requires Cloud Billing Key) - Official Docs: Solar API Documentation
- Verified Samples (1):
environmental-dashboard
- Modern APIs / Symbols:
MarkerClusterer,custom renderer returning AdvancedMarkerElement - Transport: Browser JS library (override
renderer.renderto emitAdvancedMarkerElement, never default legacyMarker) (Maps Demo Key OK) - Official Docs: MarkerClusterer Documentation
- Verified Samples (2):
real-estate,store-locator
- Modern APIs / Symbols:
GoogleMapsOverlay (@deck.gl/google-maps),HeatmapLayer (@deck.gl/aggregation-layers),ScatterplotLayer / HexagonLayer - Transport: Browser WebGL2 overlay (replaces deprecated
google.maps.visualization.HeatmapLayer) (Maps Demo Key OK) - Official Docs: deck.gl Documentation
- Verified Samples (2):
complete-heatmap,spatial-intelligence
- Modern APIs / Symbols:
TerraDraw,TerraDrawGoogleMapsAdapter (terra-draw-google-maps-adapter),TerraDrawPolygonMode - Transport: Browser JS adapter (replaces deprecated
google.maps.drawing.DrawingManager; init on mapidlewithisolatedData: true) (Maps Demo Key OK) - Official Docs: Terra Draw Documentation
- Verified Samples (3):
driving-and-geofencing,real-estate,spatial-intelligence
CRITICAL: Never emit any symbol in the second column. Always use the modern replacement in column 1 and inspect the linked verified sample.
| ✅ Use This (Modern Replacement) | ❌ Deprecated — Do Not Emit | Trigger / Error | Verified Sample(s) |
|---|---|---|---|
AdvancedMarkerElement (importLibrary('marker')) |
"google.maps.Marker is not available to new customers" (Mar 2025) | storefront-sample, store-locator, real-estate |
|
PinElement passed directly + glyphText/glyphSrc`` |
Deprecated PinElement property warnings or broken pin rendering | 3d-trail-explorer, itinerary-planner, storefront-sample |
|
PlaceAutocompleteElement (gmp-select+event.placePrediction.toPlace().fetchFields()) |
Legacy Autocomplete disabled for new customers or gmp-placeselect never firing |
storefront-sample, neighborhood-discovery, store-locator |
|
Place.searchByText() / Place.searchNearby() / Place.fetchFields() |
Legacy PlacesService disabled; need live ratings, reviews, hours, or EV chargers | neighborhood-discovery, ev-charging-map-and-dispatch, storefront-sample |
|
Inspect regularOpeningHours.periods/weekdayDescriptions(or usev: 'beta') |
"Place.prototype.isOpen() is not available in this version of the Google Maps JavaScript API" | storefront-sample, neighborhood-discovery |
|
Route.computeRoutes() / RouteMatrix.computeRouteMatrix() / Routes API v2 |
Legacy Directions/Distance Matrix disabled; need eco-routing, matrix ETAs, or waypoint optimization | ridesharing-and-tracker, store-locator, travel-route-comparator |
|
@deck.gl/google-maps GoogleMapsOverlay+HeatmapLayer/HexagonLayer`` |
Maps JS visualization library deprecated; need WebGL heatmaps or sensor density layers | complete-heatmap, spatial-intelligence |
|
terra-draw + terra-draw-google-maps-adapter (TerraDrawGoogleMapsAdapter) |
Maps JS drawing library deprecated; need interactive polygon geofencing or search-area drawing | driving-and-geofencing, real-estate, spatial-intelligence |
|
@googlemaps/js-api-loader v2 setOptions()+importLibrary()`` |
"TypeError: Loader is not a constructor" after upgrading @googlemaps/js-api-loader to v2 |
vue-vite, sveltekit, angular |
|
@vis.gl/react-google-maps (React/Next.js) / @angular/google-maps (Angular) / native Web Components (Vue/Svelte) |
React 19 peer-dep conflicts, unmaintained wrappers, or retired <gmpx-*> elements |
storefront-sample, store-locator, 3d-trail-explorer |
|
Maps JS SDK importLibrary(...)OR Server BFF/api/*proxy withX-Goog-Api-Key`` |
"Access to fetch ... has been blocked by CORS policy" | store-locator, live-order-tracking, logistics-and-routing |