android - Animate marker movements along prepared coordinates. -


i need make animated movement if airplane marker along stored coordinates in arraylist collection. i've found solution, how move marker 1 coordinate another. here code of method, moves it:

private void animatemarker(final marker plane,                            final latlng toposition,                            final boolean hidemarker,                            int currentindex) {     final handler handler = new handler();     final long start = systemclock.uptimemillis();     projection proj = gmap.getprojection();     point startpoint = proj.toscreenlocation(plane.getposition());     final latlng startlatlng = proj.fromscreenlocation(startpoint);     final long duration = 2500;      final interpolator interpolator = new linearinterpolator();      handler.post(new runnable() {         @override         public void run() {             long elapsed = systemclock.uptimemillis() - start;             float t = interpolator.getinterpolation((float) elapsed / duration);             double lat = t * toposition.latitude + (1 - t) * startlatlng.latitude;             double lng = t * toposition.longitude + (1 - t) * startlatlng.longitude;             plane.setposition(new latlng(lat, lng));              if (t < 1.0) {                 handler.postdelayed(this, 16);             } else {                 if (hidemarker) {                     plane.setvisible(false);                 } else {                     plane.setvisible(true);                 }             }         }     });     //call method start animatemarker()      // after thread finished     currentindex++;     if(currentindex < theroute.size()-1){         moveplane(plane, currentindex);     } } 

this method works perfectly, when i'm trying move object 1 coordinate another, need move along collection of coordinates. recognized, in end of code increment "currentindex" value, , call moveplane method, accepts instance of marker , new index value. here chaos starts, let me show code:

private void moveplane(marker plane, int index){     if(currentcoordindex < theroute.size()){         animatemarker(plane, theroute.get(index), false, index);     } } 

so, plane marker moving chaotically , forth coordinate , not acceptable. suppose, new thread called, when other not finished. maybe, solution quite simple, don't know how do, expect.

also need rotate marker towards next point, me that?


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -