{"record":{"id":"08d701dc4c3f5baa","repo":"angular/components","slug":"namespace-google-not-found-cannot-construct-embed","errorCode":null,"errorMessage":"Namespace google not found, cannot construct embedded google map. Please install the Google Maps JavaScript API: https://developers.google.com/maps/documentation/javascript/tutorial#Loading_the_Maps_API","messagePattern":"Namespace google not found, cannot construct embedded google map\\. Please install the Google Maps JavaScript API: https://developers\\.google\\.com/maps/documentation/javascript/tutorial#Loading_the_Maps_API","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/google-maps/google-map/google-map.ts","lineNumber":255,"sourceCode":"   */\n  @Output() readonly tiltChanged: Observable<void> =\n    this._eventManager.getLazyEmitter<void>('tilt_changed');\n\n  /**\n   * See\n   * https://developers.google.com/maps/documentation/javascript/reference/map#Map.zoom_changed\n   */\n  @Output() readonly zoomChanged: Observable<void> =\n    this._eventManager.getLazyEmitter<void>('zoom_changed');\n\n  constructor() {\n    const platformId = inject<Object>(PLATFORM_ID);\n    this._isBrowser = isPlatformBrowser(platformId);\n\n    if (this._isBrowser) {\n      const googleMapsWindow: GoogleMapsWindow = window;\n      if (!googleMapsWindow.google && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n        throw Error(\n          'Namespace google not found, cannot construct embedded google ' +\n            'map. Please install the Google Maps JavaScript API: ' +\n            'https://developers.google.com/maps/documentation/javascript/' +\n            'tutorial#Loading_the_Maps_API',\n        );\n      }\n\n      this._existingAuthFailureCallback = googleMapsWindow.gm_authFailure;\n      googleMapsWindow.gm_authFailure = () => {\n        if (this._existingAuthFailureCallback) {\n          this._existingAuthFailureCallback();\n        }\n        this.authFailure.emit();\n      };\n    }\n  }\n\n  ngOnChanges(changes: SimpleChanges<this>) {","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/google-maps/google-map/google-map.ts#L237-L273","documentation":"GoogleMap's constructor checks window.google as soon as it runs in the browser. The component does not load the Maps JS API itself; it expects the API (and the global google namespace) to be present. If not, it throws immediately, telling you to load the Maps JavaScript API.","triggerScenarios":"Rendering <google-map> in the browser when window.google is undefined — the Maps JS API script was not loaded or loaded after component construction.","commonSituations":"Using the component without the Maps JS API script tag (or missing API key/loader); lazy loading the script after Angular initializes the component; SSR-to-client hydration where the script tag is missing on the client; script blocked by CSP or network/ad blockers.","solutions":["Add the Google Maps JS API script tag before the app renders the component (with your API key).","Use a loader library like @googlemaps/js-api-loader, await its load(), then render the map component (e.g. via *ngIf).","Verify the script actually executes (check network tab, CSP, ad blockers).","For SSR, gate rendering with isPlatformBrowser and ensure client-side loading."],"exampleFix":"// before\n<google-map ...></google-map> // API script never loaded\n// after\n<script src=\"https://maps.googleapis.com/maps/api/js?key=YOUR_KEY\"></script>\n<google-map ...></google-map>","handlingStrategy":"validation","validationCode":"function isGoogleMapsLoaded(): boolean {\n  return typeof (window as any).google?.maps === 'object';\n}\n// in app init:\nif (!isGoogleMapsLoaded()) throw new Error('Load the Google Maps JS API before rendering <google-map>');","typeGuard":"function hasGoogleMaps(w: Window): w is Window & {google: {maps: any}} {\n  return typeof (w as any).google?.maps === 'object';\n}","tryCatchPattern":"try {\n  this.map.getCenter();\n} catch (e) {\n  if (String((e as Error).message).includes('Namespace google not found')) {\n    await loadGoogleMapsScript();\n  }\n}","preventionTips":["Load the Maps JS API script (with API key) before the app renders any map component.","Use *ngIf=\"apiLoaded\" so <google-map> renders only after the script loads.","Monitor network/CSP/ad-blocker issues that can block the script.","Gate rendering with isPlatformBrowser in SSR apps."],"tags":["angular","google-maps","missing-dependency","script-loading","dev-mode"],"backgroundTag":"missing-global-dependency","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}