Georgi Koemdzhiev
Georgi Koemdzhiev

Reputation: 11931

Animate map Marker in GoogleMaps API

I am trying to create a custom marker that looks like that:

enter image description here

I have the drawable in XML that looks like that:

<solid
    android:color="#0093e8"/>

<size
    android:width="120dp"
    android:height="120dp"/>

enter image description here

Is it possible to add a "Wave effect" to the marker and the waves to be fading out gradually (as in the picture)? Also, this animation should be constantly playing (without the need of the user to tap on the map marker) What should I do?

Upvotes: 1

Views: 1490

Answers (1)

Lary Ciminera
Lary Ciminera

Reputation: 1270

i did something pretty similar but i used a GroundOverlay instead of a marker, first i defined my custom animation:

public class RadiusAnimation extends Animation {
    private GroundOverlay groundOverlay;

    public RadiusAnimation(GroundOverlay groundOverlay) {
        this.groundOverlay = groundOverlay;

    }
    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        groundOverlay.setDimensions( (100 * interpolatedTime) );
        groundOverlay.setTransparency( interpolatedTime );

    }


    @Override
    public void initialize(int width, int height, int parentWidth,int parentHeight) {
        super.initialize(width, height, parentWidth, parentHeight);
    }
}

then i run animation on the groundOverlay, after onMapReady :

...
  groundOverlay = mGoogleMap.addGroundOverlay(new GroundOverlayOptions()
                    .image(image)
                    .position(new LatLng(lat, lng), 100));
  groundAnimation = new RadiusAnimation(groundOverlay);
  groundAnimation.setRepeatCount(Animation.INFINITE);
  groundAnimation.setRepeatMode(Animation.RESTART);
  groundAnimation.setDuration(2000);
  mapView.startAnimation(groundAnimation); // MapView where i show my map
...

I hope this can help you

Upvotes: 2

Related Questions