0

I am adding markers one by one to mapView by using coordinates from my database.I need to animate all markers at time.

In a loop adding animation to every added marker,but its work for only last added marker

    **code for adding markers to map is:**

    Marker marker;



         do
            {

            marker= mapView.addMarker(new MarkerOptions()
                                                .position(new LatLng(latitude, longitude))
                                                .icon(BitmapDescriptorFactory
                                                        .fromBitmap((bitmap)))
                                                .snippet(text + "             ")
                                                .title(mine_name));

   //handling animation
  applyed Bounce Interpolator
       final Handler handler = new Handler(); 
                                  final long start = SystemClock.uptimeMillis(); 
                                  Projection proj =mapView.getProjection(); 
                                  Point startPoint =proj.toScreenLocation(new LatLng( latitude,longitude)); 
                                  startPoint.offset(0, -100); 
                                  final LatLng startLatLng = proj .fromScreenLocation(startPoint);
                                  final long duration = 1500; 
                                  final Interpolator interpolator = new BounceInterpolator();
                                  handler.post(new Runnable() {

                                  @Override public void run() { 
                                      long elapsed =SystemClock.uptimeMillis() - start;
                                      float t =interpolator .getInterpolation((float) elapsed /
                                  duration); 
                                      double lng = t * new LatLng(latitude,longitude).longitude + (1 - t) *
                                  startLatLng.longitude; 
                                      double lat = t * new LatLng(latitude, longitude).latitude + (1 - t) *
                                  startLatLng.latitude; 
                                      marker.setPosition(new LatLng(lat, lng)); 
                                      if (t < 1.0) { 
                                      // Post again 16ms later.
                                  handler.postDelayed(this, 32); } } });

                }while(count>0)

But it is working for last added pin. I need to work animations for all pins at time (i.e animations reflected to pins at a same time)

Thanks in advance.

Matt Handy
  • 29,855
  • 2
  • 89
  • 112
Kumar Kalluri
  • 493
  • 2
  • 6
  • 26

0 Answers0