Skip to content

Commit

Permalink
feat(AgmMarker): add drag and dragStart event support (#1575)
Browse files Browse the repository at this point in the history
  • Loading branch information
kommundsen authored and sebholstein committed Jan 20, 2019
1 parent 3728d29 commit 1e6395d
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion packages/core/directives/marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ export class AgmMarker implements OnDestroy, OnChanges, AfterContentInit, FitBou
*/
@Output() markerRightClick: EventEmitter<void> = new EventEmitter<void>();

/**
* This event is fired when the user starts dragging the marker.
*/
@Output() dragStart: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();

/**
* This event is repeatedly fired while the user drags the marker.
*/
@Output() drag: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();

/**
* This event is fired when the user stops dragging the marker.
*/
Expand Down Expand Up @@ -240,11 +250,25 @@ export class AgmMarker implements OnDestroy, OnChanges, AfterContentInit, FitBou
this._observableSubscriptions.push(rc);

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

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

const de =
this._markerManager.createEventObservable<mapTypes.MouseEvent>('dragend', this)
.subscribe((e: mapTypes.MouseEvent) => {
this.dragEnd.emit(<MouseEvent>{coords: {lat: e.latLng.lat(), lng: e.latLng.lng()}});
});
this._observableSubscriptions.push(ds);
this._observableSubscriptions.push(de);

const mover =
this._markerManager.createEventObservable<mapTypes.MouseEvent>('mouseover', this)
Expand Down

0 comments on commit 1e6395d

Please sign in to comment.