Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit 4947efc

Browse files
committed
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
1 parent 7712b26 commit 4947efc

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/core/directives/google-map-info-window.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ let infoWindowId = 0;
3535
*/
3636
@Component({
3737
selector: 'sebm-google-map-info-window',
38-
inputs: ['latitude', 'longitude', 'disableAutoPan'],
38+
inputs: ['latitude', 'longitude', 'disableAutoPan', 'isOpen'],
3939
outputs: ['infoWindowClose'],
4040
template: `<div class='sebm-google-map-info-window-content'>
4141
<ng-content></ng-content>
@@ -87,6 +87,11 @@ export class SebmGoogleMapInfoWindow implements OnDestroy,
8787
*/
8888
content: Node;
8989

90+
/**
91+
* Sets the open state for the InfoWindow. You can also call the open() and close() methods.
92+
*/
93+
isOpen: boolean = false;
94+
9095
/**
9196
* Emits an event when the info window is closed.
9297
*/
@@ -102,6 +107,7 @@ export class SebmGoogleMapInfoWindow implements OnDestroy,
102107
this.content = this._el.nativeElement.querySelector('.sebm-google-map-info-window-content');
103108
this._infoWindowManager.addInfoWindow(this);
104109
this._infoWindowAddedToManager = true;
110+
this._updateOpenState();
105111
}
106112

107113
/** @internal */
@@ -116,9 +122,16 @@ export class SebmGoogleMapInfoWindow implements OnDestroy,
116122
if (changes['zIndex']) {
117123
this._infoWindowManager.setZIndex(this);
118124
}
125+
if (changes['isOpen']) {
126+
this._updateOpenState();
127+
}
119128
this._setInfoWindowOptions(changes);
120129
}
121130

131+
private _updateOpenState() {
132+
this.isOpen ? this._infoWindowManager.open(this) : this._infoWindowManager.close(this);
133+
}
134+
122135
private _setInfoWindowOptions(changes: {[key: string]: SimpleChange}) {
123136
let options: {[propName: string]: any} = {};
124137
let optionKeys = Object.keys(changes).filter(

0 commit comments

Comments
 (0)