How to add Animation Bounce Marker in AGM Map Angular 2+? Like this:
https://developers.google.com/maps/documentation/javascript/examples/marker-animations
PLUNKER:
http://plnkr.co/edit/YX7W20?p=preview
How to add Animation Bounce Marker in AGM Map Angular 2+? Like this:
https://developers.google.com/maps/documentation/javascript/examples/marker-animations
PLUNKER:
http://plnkr.co/edit/YX7W20?p=preview
Not sure if you're still looking for an answer to this but it seems that the marker animation is rendered/initialized before the map is even defined.
Instead, what I do is:
<agm-map
(mapReady)="mapReading()"
[zoom]="14"
[latitude]="lat"
[longitude]="lng"
></agm-map>
Then what this function does is simply:
userLocationMarkerAnimation: string;
mapReading() {
this.userLocationMarkerAnimation = 'BOUNCE';
}
And then on the marker, the binding:
<agm-marker
[animation]="userLocationMarkerAnimation"
[latitude]="lat"
[longitude]="lng"
></agm-marker>
From the library:
File: marker.d.ts
/**
* Which animation to play when marker is added to a map.
* This can be 'BOUNCE' or 'DROP'
*/
animation: 'BOUNCE' | 'DROP' | null;
So use:
<agm-marker [latitude]="lat"
[longitude]="lat"
[animation]="'BOUNCE'"
[iconUrl]="'relPath-icon.png'">
</agm-marker>
Just for info to everyone reading this. Seems that all problems they had with animation are fixed.
Now there is no need for mapReady functions and stuff like that You can put animation atribute directly on your marker, works as intended
[animation]="'BOUNCE'"
I use option to disable/enable animation on click
In your .ts file
bankina: string = 'BOUNCE'; //Set to null if you don't want it on start
bankinaAnimate(){
if (this.bankina !== null) {
this.bankina = null;
} else {
this.bankina = 'BOUNCE';
}}
And in your html file
<agm-marker
(markerClick)="bankinaAnimate()"
[animation]="bankina"