|
1 | 1 | import {Component, ElementRef, EventEmitter, OnChanges, OnInit, SimpleChange} from 'angular2/core';
|
2 | 2 | import {GoogleMapsAPIWrapper} from '../services/google-maps-api-wrapper';
|
3 | 3 | import {MarkerManager} from '../services/marker-manager';
|
4 |
| -import {LatLng} from '../services/google-maps-types'; |
| 4 | +import {LatLng, LatLngLiteral} from '../services/google-maps-types'; |
5 | 5 | import {MouseEvent} from '../events';
|
6 | 6 |
|
7 | 7 | /**
|
@@ -33,7 +33,7 @@ import {MouseEvent} from '../events';
|
33 | 33 | selector: 'sebm-google-map',
|
34 | 34 | providers: [GoogleMapsAPIWrapper, MarkerManager],
|
35 | 35 | inputs: ['longitude', 'latitude', 'zoom', 'disableDoubleClickZoom', 'disableDefaultUI'],
|
36 |
| - outputs: ['mapClick', 'mapRightClick', 'mapDblClick'], |
| 36 | + outputs: ['mapClick', 'mapRightClick', 'mapDblClick', 'centerChange'], |
37 | 37 | host: {'[class.sebm-google-map-container]': 'true'},
|
38 | 38 | styles: [`
|
39 | 39 | .sebm-google-map-container-inner {
|
@@ -85,6 +85,11 @@ export class SebmGoogleMap implements OnChanges,
|
85 | 85 | */
|
86 | 86 | mapDblClick: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();
|
87 | 87 |
|
| 88 | + /** |
| 89 | + * This event emitter is fired when the map center changes. |
| 90 | + */ |
| 91 | + centerChange: EventEmitter<LatLngLiteral> = new EventEmitter<LatLngLiteral>(); |
| 92 | + |
88 | 93 | constructor(private _elem: ElementRef, private _mapsWrapper: GoogleMapsAPIWrapper) {}
|
89 | 94 |
|
90 | 95 | /** @internal */
|
@@ -180,6 +185,7 @@ export class SebmGoogleMap implements OnChanges,
|
180 | 185 | this._mapsWrapper.getCenter().then((center: LatLng) => {
|
181 | 186 | this._latitude = center.lat();
|
182 | 187 | this._longitude = center.lng();
|
| 188 | + this.centerChange.emit(<LatLngLiteral>{lat: this._latitude, lng: this._longitude}); |
183 | 189 | });
|
184 | 190 | });
|
185 | 191 | }
|
|
0 commit comments