Skip to content

Commit

Permalink
feat: add animation field to markers
Browse files Browse the repository at this point in the history
Feature to set animation for map markers
Updated according to comments in sebholstein#852

issue: Add animation field to markers sebholstein#580
  • Loading branch information
iWebTouch committed Jan 22, 2017
1 parent 359af58 commit f4f197c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/core/directives/google-map-marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 10 additions & 8 deletions src/core/services/managers/marker-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ export class MarkerManager {
}

updateAnimation(marker: SebmGoogleMapMarker): Promise<void> {
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) {
Expand All @@ -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<Marker> {
Expand Down

0 comments on commit f4f197c

Please sign in to comment.