Skip to content

Commit

Permalink
feat(SebmGoogleMap): support zoom_changed event
Browse files Browse the repository at this point in the history
Closes #555
  • Loading branch information
Tjeerd-menno Douma authored and sebholstein committed Aug 9, 2016
1 parent 8ed927b commit df34d0e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/directives/google-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ import {MarkerManager} from '../services/managers/marker-manager';
'backgroundColor', 'draggableCursor', 'draggingCursor', 'keyboardShortcuts', 'zoomControl',
'styles', 'usePanning', 'streetViewControl', 'fitBounds', 'scaleControl'
],
outputs: ['mapClick', 'mapRightClick', 'mapDblClick', 'centerChange', 'idle', 'boundsChange'],
outputs: [
'mapClick', 'mapRightClick', 'mapDblClick', 'centerChange', 'idle', 'boundsChange', 'zoomChange'
],
host: {'[class.sebm-google-map-container]': 'true'},
styles: [`
.sebm-google-map-container-inner {
Expand Down Expand Up @@ -198,6 +200,11 @@ export class SebmGoogleMap implements OnChanges, OnInit {
*/
idle: EventEmitter<void> = new EventEmitter<void>();

/**
* This event is fired when the zoom level has changed.
*/
zoomChange: EventEmitter<number> = new EventEmitter<number>();

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

/** @internal */
Expand Down Expand Up @@ -320,7 +327,10 @@ export class SebmGoogleMap implements OnChanges, OnInit {

private _handleMapZoomChange() {
const s = this._mapsWrapper.subscribeToMapEvent<void>('zoom_changed').subscribe(() => {
this._mapsWrapper.getZoom().then((z: number) => this.zoom = z);
this._mapsWrapper.getZoom().then((z: number) => {
this.zoom = z;
this.zoomChange.emit(z);
});
});
this._observableSubscriptions.push(s);
}
Expand Down

1 comment on commit df34d0e

@brian-singer
Copy link
Contributor

Choose a reason for hiding this comment

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

👌🏻

Please sign in to comment.