diff --git a/packages/core/directives/map.ts b/packages/core/directives/map.ts index 3301a50af..7c1c696fb 100644 --- a/packages/core/directives/map.ts +++ b/packages/core/directives/map.ts @@ -374,6 +374,9 @@ export class AgmMap implements OnChanges, OnInit, OnDestroy { ngOnDestroy() { // unsubscribe all registered observable subscriptions this._observableSubscriptions.forEach((s) => s.unsubscribe()); + + // remove all listeners from the map instance + this._mapsWrapper.clearInstanceListeners(); } /* @internal */ diff --git a/packages/core/services/google-maps-api-wrapper.ts b/packages/core/services/google-maps-api-wrapper.ts index decbc5a01..29f129b90 100644 --- a/packages/core/services/google-maps-api-wrapper.ts +++ b/packages/core/services/google-maps-api-wrapper.ts @@ -107,6 +107,12 @@ export class GoogleMapsAPIWrapper { }); } + clearInstanceListeners() { + this._map.then((map: mapTypes.GoogleMap) => { + google.maps.event.clearInstanceListeners(map); + }); + } + setCenter(latLng: mapTypes.LatLngLiteral): Promise { return this._map.then((map: mapTypes.GoogleMap) => map.setCenter(latLng)); }