Skip to content

Commit

Permalink
feat(InfoWindow): support initial open state
Browse files Browse the repository at this point in the history
The new isOpen binding adds support for setting
the open state in a declarative way.

Closes #382
Closes #390
  • Loading branch information
sebholstein committed Jun 6, 2016
1 parent 7712b26 commit 4947efc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/core/directives/google-map-info-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<div class='sebm-google-map-info-window-content'>
<ng-content></ng-content>
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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 */
Expand All @@ -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(
Expand Down

1 comment on commit 4947efc

@brian-singer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super danke!!

Please sign in to comment.