Skip to content

Commit

Permalink
feat(SebmGoogleMap): support centerChange event
Browse files Browse the repository at this point in the history
Closes #212
  • Loading branch information
sebholstein committed Mar 11, 2016
1 parent 206df76 commit 20ad62b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/directives/google-map.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Component, ElementRef, EventEmitter, OnChanges, OnInit, SimpleChange} from 'angular2/core';
import {GoogleMapsAPIWrapper} from '../services/google-maps-api-wrapper';
import {MarkerManager} from '../services/marker-manager';
import {LatLng} from '../services/google-maps-types';
import {LatLng, LatLngLiteral} from '../services/google-maps-types';
import {MouseEvent} from '../events';

/**
Expand Down Expand Up @@ -33,7 +33,7 @@ import {MouseEvent} from '../events';
selector: 'sebm-google-map',
providers: [GoogleMapsAPIWrapper, MarkerManager],
inputs: ['longitude', 'latitude', 'zoom', 'disableDoubleClickZoom', 'disableDefaultUI'],
outputs: ['mapClick', 'mapRightClick', 'mapDblClick'],
outputs: ['mapClick', 'mapRightClick', 'mapDblClick', 'centerChange'],
host: {'[class.sebm-google-map-container]': 'true'},
styles: [`
.sebm-google-map-container-inner {
Expand Down Expand Up @@ -85,6 +85,11 @@ export class SebmGoogleMap implements OnChanges,
*/
mapDblClick: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();

/**
* This event emitter is fired when the map center changes.
*/
centerChange: EventEmitter<LatLngLiteral> = new EventEmitter<LatLngLiteral>();

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

/** @internal */
Expand Down Expand Up @@ -180,6 +185,7 @@ export class SebmGoogleMap implements OnChanges,
this._mapsWrapper.getCenter().then((center: LatLng) => {
this._latitude = center.lat();
this._longitude = center.lng();
this.centerChange.emit(<LatLngLiteral>{lat: this._latitude, lng: this._longitude});
});
});
}
Expand Down

0 comments on commit 20ad62b

Please sign in to comment.