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' ;
2
3
import { Subscription } from 'rxjs/Subscription' ;
3
4
4
5
import { MouseEvent } from '../map-types' ;
@@ -119,7 +120,7 @@ export class SebmGoogleMapMarker implements OnDestroy, OnChanges, AfterContentIn
119
120
/**
120
121
* @internal
121
122
*/
122
- @ContentChild ( SebmGoogleMapInfoWindow ) infoWindow : SebmGoogleMapInfoWindow ;
123
+ @ContentChildren ( SebmGoogleMapInfoWindow ) infoWindow : QueryList < SebmGoogleMapInfoWindow > = new QueryList < SebmGoogleMapInfoWindow > ( ) ;
123
124
124
125
private _markerAddedToManger : boolean = false ;
125
126
private _id : string ;
@@ -129,9 +130,17 @@ export class SebmGoogleMapMarker implements OnDestroy, OnChanges, AfterContentIn
129
130
130
131
/* @internal */
131
132
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.' ) ;
134
140
}
141
+ this . infoWindow . forEach ( marker => {
142
+ marker . hostMarker = this ;
143
+ } ) ;
135
144
}
136
145
137
146
/** @internal */
@@ -173,8 +182,8 @@ export class SebmGoogleMapMarker implements OnDestroy, OnChanges, AfterContentIn
173
182
174
183
private _addEventListeners ( ) {
175
184
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 ( ) ) ;
178
187
}
179
188
this . markerClick . emit ( null ) ;
180
189
} ) ;
0 commit comments