0

in iOS, Google Map allow to provide an animation when Marker pop on map.

I'am looking to do the same on Android. So there is nothing to do it or someone know a workaround?

TomJouin
  • 49
  • 10

2 Answers2

0

You can animate marker with general Android approach: Animations and Transitions. Use this or that as examples:

private static void animateMarker(final Marker marker, final int current, final LatLng[] line) {
    if (line == null || line.length == 0 || current >= line.length) {
        return;
    }

    ObjectAnimator animator = ObjectAnimator.ofObject(marker, property, typeEvaluator, line[current]);
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            animateMarker(marker, current + 1, line);
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });

    animator.setDuration(DURATION);
    animator.start();
}

or use libraries, like that.

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
0

As per your response from the server, you receive/extract the latitude and longitude.

 //call this method for adding marker with lat and long

    public void addmarker(){
     LatLng marker = new LatLng(double lat, double long);
            googleMap.addMarker(new MarkerOptions().position(marker)
                    .title("My title"));
            googleMap.moveCamera(CameraUpdateFactory.newLatLng(marker));
// now the marker is set
// add a delay of 100-200 ms and start you animation (delay for failsafe)
    }
nimi0112
  • 2,065
  • 1
  • 18
  • 32
  • I don't want to move the camera to the new marker i want to make an animation on markers when they all appear (For exemple it can be a fade) To avoid the default instant pop – TomJouin Mar 12 '18 at 10:24
  • @TomJouin How the user will see the animation if you do not move the camera towards the position where you have put the marker. – nimi0112 Mar 12 '18 at 13:15
  • The map is zoom over Paris, and have many marker on map. When i select a particular date that show every marker at this date on map. I know how to move camera on map. What I want to do is have a custom animation to my marker when he appear. Not moove the camera. – TomJouin Mar 12 '18 at 13:59
  • @TomJouin Hey buddy, I know you may have already solved it but if not It is a very simple thing. everything lies in your code just do it step by step like looking into it when you are showing all the required markers on the screen to the user and starting your animation after it. Thank you – nimi0112 Mar 13 '18 at 06:47
  • No it isn't a very simple thing. – TomJouin Mar 16 '18 at 10:24