Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit f4f197c

Browse files
committed
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
1 parent 359af58 commit f4f197c

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/core/directives/google-map-marker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ export class SebmGoogleMapMarker implements OnDestroy, OnChanges, AfterContentIn
9999

100100
/**
101101
* Which animation to play when marker is added to a map.
102-
* This can be "bounce" or "drop"
102+
* This can be 'BOUNCE' or 'DROP'
103103
*/
104-
animation: string;
104+
animation: 'BOUNCE' | 'DROP' | null;
105105

106106
/**
107107
* This event emitter gets emitted when the user clicks on the marker.

src/core/services/managers/marker-manager.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ export class MarkerManager {
6464
}
6565

6666
updateAnimation(marker: SebmGoogleMapMarker): Promise<void> {
67-
return this._markers.get(marker).then((m: Marker) =>
68-
m.setAnimation(google.maps.Animation[marker.animation])
69-
);
67+
return this._markers.get(marker).then((m: Marker) => {
68+
if (typeof marker.animation === 'string') {
69+
m.setAnimation(google.maps.Animation[marker.animation]);
70+
} else {
71+
m.setAnimation(marker.animation);
72+
}
73+
});
7074
}
7175

7276
addMarker(marker: SebmGoogleMapMarker) {
@@ -78,13 +82,11 @@ export class MarkerManager {
7882
opacity: marker.opacity,
7983
visible: marker.visible,
8084
zIndex: marker.zIndex,
81-
title: marker.title
85+
title: marker.title,
86+
animation: (typeof marker.animation === 'string') ? google.maps.Animation[marker.animation] : marker.animation
8287
});
83-
this._markers.set(marker, markerPromise);
8488

85-
markerPromise.then((m: Marker) =>
86-
m.setAnimation(google.maps.Animation[marker.animation])
87-
);
89+
this._markers.set(marker, markerPromise);
8890
}
8991

9092
getNativeMarker(marker: SebmGoogleMapMarker): Promise<Marker> {

0 commit comments

Comments
 (0)