From f4f197ccd90afcc7f09bc98c0a415d9fb2f4981a Mon Sep 17 00:00:00 2001 From: Xdimension Date: Sun, 22 Jan 2017 21:15:46 +0700 Subject: [PATCH] feat: add animation field to markers Feature to set animation for map markers Updated according to comments in #852 issue: Add animation field to markers #580 --- src/core/directives/google-map-marker.ts | 4 ++-- src/core/services/managers/marker-manager.ts | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/core/directives/google-map-marker.ts b/src/core/directives/google-map-marker.ts index e52579351..ed83981e2 100644 --- a/src/core/directives/google-map-marker.ts +++ b/src/core/directives/google-map-marker.ts @@ -99,9 +99,9 @@ export class SebmGoogleMapMarker implements OnDestroy, OnChanges, AfterContentIn /** * Which animation to play when marker is added to a map. - * This can be "bounce" or "drop" + * This can be 'BOUNCE' or 'DROP' */ - animation: string; + animation: 'BOUNCE' | 'DROP' | null; /** * This event emitter gets emitted when the user clicks on the marker. diff --git a/src/core/services/managers/marker-manager.ts b/src/core/services/managers/marker-manager.ts index c14d6d60c..55ab10c33 100644 --- a/src/core/services/managers/marker-manager.ts +++ b/src/core/services/managers/marker-manager.ts @@ -64,9 +64,13 @@ export class MarkerManager { } updateAnimation(marker: SebmGoogleMapMarker): Promise { - return this._markers.get(marker).then((m: Marker) => - m.setAnimation(google.maps.Animation[marker.animation]) - ); + return this._markers.get(marker).then((m: Marker) => { + if (typeof marker.animation === 'string') { + m.setAnimation(google.maps.Animation[marker.animation]); + } else { + m.setAnimation(marker.animation); + } + }); } addMarker(marker: SebmGoogleMapMarker) { @@ -78,13 +82,11 @@ export class MarkerManager { opacity: marker.opacity, visible: marker.visible, zIndex: marker.zIndex, - title: marker.title + title: marker.title, + animation: (typeof marker.animation === 'string') ? google.maps.Animation[marker.animation] : marker.animation }); - this._markers.set(marker, markerPromise); - markerPromise.then((m: Marker) => - m.setAnimation(google.maps.Animation[marker.animation]) - ); + this._markers.set(marker, markerPromise); } getNativeMarker(marker: SebmGoogleMapMarker): Promise {