7

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...

Renjith
  • 5,783
  • 9
  • 31
  • 42
user1793188
  • 81
  • 1
  • 2

3 Answers3

13

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();

                }
            }
        });
    }
Md. Monsur Hossain Tonmoy
  • 11,045
  • 2
  • 22
  • 19
3

Check this thread and this thread

Android has overlay markers (see ItemizedOverlay) that make it easy to add images to maps, BUT note that, in my experience at least, animated images do not work when added to overlays.

But to be honest, you should remember that it's Android, and copying every little feature from iOS is unnecessary. Google Maps on Android doesn't use a pin marker, it uses a static blue spot - I'd say it's best to replicate that and remember your users are Android users, not iOS users - they want consistency across Android apps

Community
  • 1
  • 1
san
  • 1,845
  • 13
  • 23
  • Hi San, After looking into the first thread (http://stackoverflow.com/questions/10607042/tutorial-android-map-pin-drop-animation-working-right), i have a doubt in this: here mapOverlays.add(itemOverlay); I could not find function or class related to it. What does it mean? and what should i need to do here – user1793188 Nov 02 '12 at 04:32
  • Check these links out. It is MapOverlay. http://mobiforge.com/developing/story/using-google-maps-android https://developers.google.com/maps/documentation/android/hello-mapview – san Nov 02 '12 at 05:58
-1

to implement falling pin animation in gps follow the link

http://www.codeproject.com/Articles/112044/GPSLocator-App-to-Find-Current-Nearest-Location-us

Sumedh Tambat
  • 801
  • 1
  • 11
  • 24
  • hi sumedh, i was able to do all those stuff. But i want to do custom markers that appear falling on google maps automatically. More precisely, they should appear as if the are falling on maps from a height. When the map is loaded, markers should fall on the map from the place near you. – user1793188 Nov 02 '12 at 04:20