From 019f731df1e1b4a5439f02c75a89a7d4295b99d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20M=C3=BCller?= Date: Thu, 15 Sep 2016 21:15:38 +0200 Subject: [PATCH] fix(SebmGoogleMapCircle): removing circles Fixes #650 --- src/core/directives/google-map-circle.ts | 1 + src/core/services/managers/circle-manager.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/core/directives/google-map-circle.ts b/src/core/directives/google-map-circle.ts index f0d063082..e5a67e3e1 100644 --- a/src/core/directives/google-map-circle.ts +++ b/src/core/directives/google-map-circle.ts @@ -247,6 +247,7 @@ export class SebmGoogleMapCircle implements OnInit, OnChanges, OnDestroy { ngOnDestroy() { this._eventSubscriptions.forEach(function(s: Subscription) { s.unsubscribe(); }); this._eventSubscriptions = null; + this._manager.removeCircle(this); } /** diff --git a/src/core/services/managers/circle-manager.ts b/src/core/services/managers/circle-manager.ts index 6c95e1463..1793f587b 100644 --- a/src/core/services/managers/circle-manager.ts +++ b/src/core/services/managers/circle-manager.ts @@ -32,6 +32,16 @@ export class CircleManager { })); }; + /** + * Removes the given circle from the map. + */ + removeCircle(circle: SebmGoogleMapCircle): Promise { + return this._circles.get(circle).then((c) => { + c.setMap(null); + this._circles.delete(circle); + }); + } + setOptions(circle: SebmGoogleMapCircle, options: mapTypes.CircleOptions): Promise { return this._circles.get(circle).then((c) => c.setOptions(options)); };