Skip to content

Commit

Permalink
feat(marker): support mouseover and mouseout event
Browse files Browse the repository at this point in the history
Closes #662
  • Loading branch information
staticint authored and sebholstein committed Sep 20, 2016
1 parent aac39db commit 59ba45b
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/core/directives/google-map-marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let markerId = 0;
'latitude', 'longitude', 'title', 'label', 'draggable: markerDraggable', 'iconUrl',
'openInfoWindow', 'fitBounds', 'opacity', 'visible', 'zIndex'
],
outputs: ['markerClick', 'dragEnd']
outputs: ['markerClick', 'dragEnd', 'mouseOver', 'mouseOut']
})
export class SebmGoogleMapMarker implements OnDestroy, OnChanges, AfterContentInit {
/**
Expand Down Expand Up @@ -106,6 +106,16 @@ export class SebmGoogleMapMarker implements OnDestroy, OnChanges, AfterContentIn
*/
dragEnd: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();

/**
* This event is fired when the user mouses over the marker.
*/
mouseOver: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();

/**
* This event is fired when the user mouses outside the marker.
*/
mouseOut: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();

@ContentChild(SebmGoogleMapInfoWindow) private _infoWindow: SebmGoogleMapInfoWindow;

private _markerAddedToManger: boolean = false;
Expand Down Expand Up @@ -173,6 +183,20 @@ export class SebmGoogleMapMarker implements OnDestroy, OnChanges, AfterContentIn
this.dragEnd.emit(<MouseEvent>{coords: {lat: e.latLng.lat(), lng: e.latLng.lng()}});
});
this._observableSubscriptions.push(ds);

const mover =
this._markerManager.createEventObservable<mapTypes.MouseEvent>('mouseover', this)
.subscribe((e: mapTypes.MouseEvent) => {
this.mouseOver.emit(<MouseEvent>{coords: {lat: e.latLng.lat(), lng: e.latLng.lng()}});
});
this._observableSubscriptions.push(mover);

const mout =
this._markerManager.createEventObservable<mapTypes.MouseEvent>('mouseout', this)
.subscribe((e: mapTypes.MouseEvent) => {
this.mouseOut.emit(<MouseEvent>{coords: {lat: e.latLng.lat(), lng: e.latLng.lng()}});
});
this._observableSubscriptions.push(mout);
}

/** @internal */
Expand Down

0 comments on commit 59ba45b

Please sign in to comment.