Skip to content

Commit

Permalink
feat(AgmMap): Add tilesloaded event to AgmMap (#1706)
Browse files Browse the repository at this point in the history
fixes: #1701
  • Loading branch information
CorneeSean authored and doom777 committed Aug 20, 2019
1 parent df05277 commit d4f1371
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/core/directives/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ export class AgmMap implements OnChanges, OnInit, OnDestroy {
*/
@Output() mapReady: EventEmitter<any> = new EventEmitter<any>();

/**
* This event is fired when the visible tiles have finished loading.
*/
@Output() tilesLoaded: EventEmitter<void> = new EventEmitter<void>();

constructor(private _elem: ElementRef, private _mapsWrapper: GoogleMapsAPIWrapper, protected _fitBoundsService: FitBoundsService, private _zone: NgZone) {
}

Expand Down Expand Up @@ -413,6 +418,7 @@ export class AgmMap implements OnChanges, OnInit, OnDestroy {
this._handleMapMouseEvents();
this._handleBoundsChange();
this._handleMapTypeIdChange();
this._handleTilesLoadedEvent();
this._handleIdleEvent();
}

Expand Down Expand Up @@ -577,6 +583,13 @@ export class AgmMap implements OnChanges, OnInit, OnDestroy {
this._observableSubscriptions.push(s);
}

private _handleTilesLoadedEvent() {
const s = this._mapsWrapper.subscribeToMapEvent<void>('tilesloaded').subscribe(
() => this.tilesLoaded.emit(void 0)
);
this._observableSubscriptions.push(s);
}

private _handleMapMouseEvents() {
interface Emitter {
emit(value: any): void;
Expand Down

0 comments on commit d4f1371

Please sign in to comment.