Skip to content

Commit

Permalink
feat(SebmGoogleMap): support idle event
Browse files Browse the repository at this point in the history
This event is fired when the map becomes idle after panning or
zooming.

Example:

```
<sebm-google-map [latitude]="lat" [longitude]="lng" (idle)="myMethod">
</sebm-google-map>
```

Closes #393
Closes #417
  • Loading branch information
sebholstein committed Jun 11, 2016
1 parent 760f410 commit c5d5744
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/core/directives/google-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {MarkerManager} from '../services/marker-manager';
'backgroundColor', 'draggableCursor', 'draggingCursor', 'keyboardShortcuts', 'zoomControl',
'styles', 'usePanning'
],
outputs: ['mapClick', 'mapRightClick', 'mapDblClick', 'centerChange'],
outputs: ['mapClick', 'mapRightClick', 'mapDblClick', 'centerChange', 'idle'],
host: {'[class.sebm-google-map-container]': 'true'},
styles: [`
.sebm-google-map-container-inner {
Expand Down Expand Up @@ -168,6 +168,11 @@ export class SebmGoogleMap implements OnChanges,
*/
centerChange: EventEmitter<LatLngLiteral> = new EventEmitter<LatLngLiteral>();

/**
* This event is fired when the map becomes idle after panning or zooming.
*/
idle: EventEmitter<void> = new EventEmitter<void>();

constructor(private _elem: ElementRef, private _mapsWrapper: GoogleMapsAPIWrapper) {}

/** @internal */
Expand All @@ -191,6 +196,7 @@ export class SebmGoogleMap implements OnChanges,
this._handleMapCenterChange();
this._handleMapZoomChange();
this._handleMapMouseEvents();
this._handleIdleEvent();
}

/* @internal */
Expand Down Expand Up @@ -254,6 +260,11 @@ export class SebmGoogleMap implements OnChanges,
});
}

private _handleIdleEvent() {
this._mapsWrapper.subscribeToMapEvent<void>('idle').subscribe(
() => { this.idle.emit(void 0); });
}

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

1 comment on commit c5d5744

@NoTra
Copy link

@NoTra NoTra commented on c5d5744 Jun 12, 2016

Choose a reason for hiding this comment

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

Awesome :)

Please sign in to comment.