Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement falling pin animation on google maps android

I am implementing google maps in my android app. In this process I would like to add falling pin animation. I have searched every were but could not find the exact method to do this. Can any one help me out how to do will be a great help...

like image 724
user1793188 Avatar asked Nov 02 '12 03:11

user1793188


People also ask

Can androids drop a pin on Google Maps?

Share a map or location Or, find a place on the map, then touch and hold to drop a pin. At the bottom, tap the place's name or address. Share. Choose the app where you want to share the link to the map.


1 Answers

Add marker to desired position in map then call this function with that marker

private void dropPinEffect(final Marker marker) {
        final Handler handler = new Handler();
        final long start = SystemClock.uptimeMillis();
        final long duration = 1500;

        final Interpolator interpolator = new BounceInterpolator();

        handler.post(new Runnable() {
            @Override
            public void run() {
                long elapsed = SystemClock.uptimeMillis() - start;
                float t = Math.max(
                        1 - interpolator.getInterpolation((float) elapsed
                                / duration), 0);
                marker.setAnchor(0.5f, 1.0f + 14 * t);

                if (t > 0.0) {
                    // Post again 15ms later.
                    handler.postDelayed(this, 15);
                } else {
                    marker.showInfoWindow();

                }
            }
        });
    }
like image 94
Md. Monsur Hossain Tonmoy Avatar answered Nov 15 '22 00:11

Md. Monsur Hossain Tonmoy