1- import { AfterContentInit , ContentChild , Directive , EventEmitter , OnChanges , OnDestroy , SimpleChange } from '@angular/core' ;
1+ import { Directive , EventEmitter , OnChanges , OnDestroy , SimpleChange ,
2+ AfterContentInit , ContentChildren , QueryList } from '@angular/core' ;
23import { Subscription } from 'rxjs/Subscription' ;
34
45import { MouseEvent } from '../map-types' ;
@@ -119,7 +120,7 @@ export class SebmGoogleMapMarker implements OnDestroy, OnChanges, AfterContentIn
119120 /**
120121 * @internal
121122 */
122- @ContentChild ( SebmGoogleMapInfoWindow ) infoWindow : SebmGoogleMapInfoWindow ;
123+ @ContentChildren ( SebmGoogleMapInfoWindow ) infoWindow : QueryList < SebmGoogleMapInfoWindow > = new QueryList < SebmGoogleMapInfoWindow > ( ) ;
123124
124125 private _markerAddedToManger : boolean = false ;
125126 private _id : string ;
@@ -129,9 +130,17 @@ export class SebmGoogleMapMarker implements OnDestroy, OnChanges, AfterContentIn
129130
130131 /* @internal */
131132 ngAfterContentInit ( ) {
132- if ( this . infoWindow != null ) {
133- this . infoWindow . hostMarker = this ;
133+ this . handleInfoWindowUpdate ( ) ;
134+ this . infoWindow . changes . subscribe ( ( ) => this . handleInfoWindowUpdate ( ) ) ;
135+ }
136+
137+ private handleInfoWindowUpdate ( ) {
138+ if ( this . infoWindow . length > 1 ) {
139+ throw new Error ( 'Expected no more than one info window.' ) ;
134140 }
141+ this . infoWindow . forEach ( marker => {
142+ marker . hostMarker = this ;
143+ } ) ;
135144 }
136145
137146 /** @internal */
@@ -173,8 +182,8 @@ export class SebmGoogleMapMarker implements OnDestroy, OnChanges, AfterContentIn
173182
174183 private _addEventListeners ( ) {
175184 const cs = this . _markerManager . createEventObservable ( 'click' , this ) . subscribe ( ( ) => {
176- if ( this . openInfoWindow && this . infoWindow != null ) {
177- this . infoWindow . open ( ) ;
185+ if ( this . openInfoWindow ) {
186+ this . infoWindow . forEach ( infoWindow => infoWindow . open ( ) ) ;
178187 }
179188 this . markerClick . emit ( null ) ;
180189 } ) ;
0 commit comments