@@ -23,12 +23,14 @@ import {
2323 PLATFORM_ID ,
2424 NgZone ,
2525 SimpleChanges ,
26+ EventEmitter ,
2627} from '@angular/core' ;
2728import { isPlatformBrowser } from '@angular/common' ;
2829import { Observable } from 'rxjs' ;
2930import { MapEventManager } from '../map-event-manager' ;
3031
3132interface GoogleMapsWindow extends Window {
33+ gm_authFailure ?: ( ) => void ;
3234 google ?: typeof google ;
3335}
3436
@@ -60,6 +62,7 @@ export const DEFAULT_WIDTH = '500px';
6062export class GoogleMap implements OnChanges , OnInit , OnDestroy {
6163 private _eventManager : MapEventManager = new MapEventManager ( this . _ngZone ) ;
6264 private _mapEl : HTMLElement ;
65+ private _existingAuthFailureCallback : GoogleMapsWindow [ 'gm_authFailure' ] ;
6366
6467 /**
6568 * The underlying google.maps.Map object
@@ -101,6 +104,12 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
101104 }
102105 private _options = DEFAULT_OPTIONS ;
103106
107+ /**
108+ * See
109+ * https://developers.google.com/maps/documentation/javascript/events#auth-errors
110+ */
111+ @Output ( ) readonly authFailure : EventEmitter < void > = new EventEmitter < void > ( ) ;
112+
104113 /**
105114 * See
106115 * https://developers.google.com/maps/documentation/javascript/reference/map#Map.bounds_changed
@@ -245,6 +254,14 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
245254 'https://developers.google.com/maps/documentation/javascript/' +
246255 'tutorial#Loading_the_Maps_API' ) ;
247256 }
257+
258+ this . _existingAuthFailureCallback = googleMapsWindow . gm_authFailure ;
259+ googleMapsWindow . gm_authFailure = ( ) => {
260+ if ( this . _existingAuthFailureCallback ) {
261+ this . _existingAuthFailureCallback ( ) ;
262+ }
263+ this . authFailure . emit ( ) ;
264+ } ;
248265 }
249266 }
250267
@@ -293,6 +310,11 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
293310
294311 ngOnDestroy ( ) {
295312 this . _eventManager . destroy ( ) ;
313+
314+ if ( this . _isBrowser ) {
315+ const googleMapsWindow : GoogleMapsWindow = window ;
316+ googleMapsWindow . gm_authFailure = this . _existingAuthFailureCallback ;
317+ }
296318 }
297319
298320 /**
0 commit comments