Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(InfoWindow): support initial open state #390

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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