From 1e6395dd53633b4cdf193d6cfb4b68c984d27785 Mon Sep 17 00:00:00 2001 From: Kim Ommundsen Date: Sun, 20 Jan 2019 08:46:50 +0100 Subject: [PATCH] feat(AgmMarker): add drag and dragStart event support (#1575) --- packages/core/directives/marker.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/core/directives/marker.ts b/packages/core/directives/marker.ts index b663bda63..3895bfad9 100644 --- a/packages/core/directives/marker.ts +++ b/packages/core/directives/marker.ts @@ -120,6 +120,16 @@ export class AgmMarker implements OnDestroy, OnChanges, AfterContentInit, FitBou */ @Output() markerRightClick: EventEmitter = new EventEmitter(); + /** + * This event is fired when the user starts dragging the marker. + */ + @Output() dragStart: EventEmitter = new EventEmitter(); + + /** + * This event is repeatedly fired while the user drags the marker. + */ + @Output() drag: EventEmitter = new EventEmitter(); + /** * This event is fired when the user stops dragging the marker. */ @@ -240,11 +250,25 @@ export class AgmMarker implements OnDestroy, OnChanges, AfterContentInit, FitBou this._observableSubscriptions.push(rc); const ds = + this._markerManager.createEventObservable('dragstart', this) + .subscribe((e: mapTypes.MouseEvent) => { + this.dragStart.emit({coords: {lat: e.latLng.lat(), lng: e.latLng.lng()}}); + }); + this._observableSubscriptions.push(ds); + + const d = + this._markerManager.createEventObservable('drag', this) + .subscribe((e: mapTypes.MouseEvent) => { + this.drag.emit({coords: {lat: e.latLng.lat(), lng: e.latLng.lng()}}); + }); + this._observableSubscriptions.push(d); + + const de = this._markerManager.createEventObservable('dragend', this) .subscribe((e: mapTypes.MouseEvent) => { this.dragEnd.emit({coords: {lat: e.latLng.lat(), lng: e.latLng.lng()}}); }); - this._observableSubscriptions.push(ds); + this._observableSubscriptions.push(de); const mover = this._markerManager.createEventObservable('mouseover', this)