4

Please can someone help me to add animated marker like this one for android google maps V2

thank you.

Abdel
  • 1,005
  • 2
  • 11
  • 24

2 Answers2

-1

Maybe you may get idea studying it......

TranslateAnimation animation = new TranslateAnimation(0.0f, 400.0f,0.0f, 0.0f);
//new TranslateAnimation(xFrom,xTo, yFrom,yTo)

animation.setDuration(2000);  // animation duration 
animation.setRepeatCount(100);  // animation repeat count (total repetition)
animation.setRepeatMode(2);   // repeat animation (left to right, right to left )
//animation.setFillAfter(true);      

img_animation.startAnimation(animation);
Naveed Ashraf
  • 295
  • 2
  • 6
-4

please use below code to set marker from drawable

       BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.current_position_tennis_ball)


        MarkerOptions markerOptions = new MarkerOptions().position(latLng)
                 .title("Current Location")
                 .snippet("Thinking of finding some thing...")
                 .icon(icon);

        mMarker = googleMap.addMarker(markerOptions);
prakash
  • 466
  • 4
  • 18
  • 4
    Please feel free to explain how this will achieve any sort of animated effect. – CommonsWare Nov 22 '13 at 16:29
  • @CommonsWare why do you think this wouldnt work? I have not tried Prakash solution but theoritically you can link it to drawable xml which has a set of images displaying say every 200ms.. Wouldn't that animate the image? – Snake Nov 15 '14 at 04:11
  • @Snake: You are assuming that `BitmapDescriptor` is capable of dealing with animations, and I am assuming that it is not (if it were, they would have named it `DrawableDescriptor` instead of `BitmapDescriptor`). This is why I suggested to the answerer that an explanation is in order. – CommonsWare Nov 15 '14 at 12:33
  • Oh good point. I guess I will try it and find which theory applies. Although your answer made me lose hope as I was looking for a way to animate markers – Snake Nov 15 '14 at 17:01
  • @CommonsWare. And you win! (I am not surprised by the way lol). I tried it and it was crashing with null pointer somehwere in google library. IT is really annoying that there is no way way you can animate Markers in an easier way. Unless offcourse I missing it – Snake Nov 17 '14 at 17:21