From 4947efcc440e8ce2c7803d52e05caa99dc3a7bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20M=C3=BCller?= Date: Mon, 6 Jun 2016 22:28:25 +0200 Subject: [PATCH] feat(InfoWindow): support initial open state The new isOpen binding adds support for setting the open state in a declarative way. Closes #382 Closes #390 --- src/core/directives/google-map-info-window.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/directives/google-map-info-window.ts b/src/core/directives/google-map-info-window.ts index a243bfa3a..b9c7b0200 100644 --- a/src/core/directives/google-map-info-window.ts +++ b/src/core/directives/google-map-info-window.ts @@ -35,7 +35,7 @@ let infoWindowId = 0; */ @Component({ selector: 'sebm-google-map-info-window', - inputs: ['latitude', 'longitude', 'disableAutoPan'], + inputs: ['latitude', 'longitude', 'disableAutoPan', 'isOpen'], outputs: ['infoWindowClose'], template: `
@@ -87,6 +87,11 @@ export class SebmGoogleMapInfoWindow implements OnDestroy, */ content: Node; + /** + * Sets the open state for the InfoWindow. You can also call the open() and close() methods. + */ + isOpen: boolean = false; + /** * Emits an event when the info window is closed. */ @@ -102,6 +107,7 @@ export class SebmGoogleMapInfoWindow implements OnDestroy, this.content = this._el.nativeElement.querySelector('.sebm-google-map-info-window-content'); this._infoWindowManager.addInfoWindow(this); this._infoWindowAddedToManager = true; + this._updateOpenState(); } /** @internal */ @@ -116,9 +122,16 @@ export class SebmGoogleMapInfoWindow implements OnDestroy, if (changes['zIndex']) { this._infoWindowManager.setZIndex(this); } + if (changes['isOpen']) { + this._updateOpenState(); + } this._setInfoWindowOptions(changes); } + private _updateOpenState() { + this.isOpen ? this._infoWindowManager.open(this) : this._infoWindowManager.close(this); + } + private _setInfoWindowOptions(changes: {[key: string]: SimpleChange}) { let options: {[propName: string]: any} = {}; let optionKeys = Object.keys(changes).filter(