Depict a person's one-month trajectory history and replay it in chronological order. Younger brother rookie one, code quality is not high, master do not spray, thank you.
About the strokes and strokes, Baidu Map has its own API, everyone should be, as for playing animation, there is certainly more than one way, if you have a good way to share out, younger brother grateful.
My method is: In a thread, after starting to play, traversing the list of the item, find the current item, remove his marker, then give him a marker, then add to the list, and then sleep, and then judge, if not the current item, What it looks like, so iterate on it.
The code is as follows:
/**Track Playback logic processing **/PrivateRunnable RZ =NewRunnable () {@Override Public synchronized voidrun () { while(isstartrun) { for(inti = index; I < mgeolist.size (); i++) {Overlayitem Item=Mgeolist.get (i); Flag=index; Sendmsg (Mapapplication.locateover_notice_adapter); Moverlaygraphic.removeitem (item); Item.setmarker (Res.get (3)); if(!Isbcak) { Break; } moverlaygraphic.additem (item); Mmapview.refresh (); Systemutils.sleep (1000); Moverlaygraphic.removeitem (item); if(Index = = 0) {Item.setmarker (Res.get (1)); } Else if(Index = = mgeolist.size ()-1) {Item.setmarker (Res.get (2)); Isstartrun=false; Isfinish=false; } Else{View View= Minflater.inflate (R.layout.overlay_item,NULL); TextView UserItemTv1=(TextView) View.findviewbyid (R.ID.ITEM_TV1); Useritemtv1.settext (Index+ 1 + ""); Bitmap BMP=userlocateutil.createnewbitmap (view); Drawable drawable=Newbitmapdrawable (BMP); Item.setmarker (drawable); } if(!Isbcak) { Break; } moverlaygraphic.additem (item); Mmapview.refresh (); Index++; if(!isfinish) {Index= 0; Sendmsg (Mapapplication.locateover_play_finish); Break; } } } }}; PrivateHandler Handler =NewHandler () { Public voidhandlemessage (Message msg) {Switch(msg.what) { CaseMapApplication.LOCATEOVER_CHANGE_MAPVIEW:changeMapView (); Break; CaseMapApplication.LOCATE_MAPVIEW_REFRESH:mMapView.refresh (); Mmapview.getcontroller (). Zoomtospan (Moverlaygraphic.getlatspane6 (), Moverlaygraphic.getlonspane6 ()); Mmapview.getcontroller (). SetCenter (Moverlaygraphic.getcenter ()); Pocprogressdialog.cancel (); Break; CaseMapApplication.LOCATEOVER_PLAY_FINISH:Toast.makeText (mainactivity.mainactivity,"Play Complete", Toast.length_short). Show (); Flag= 99999; Adapter.notifydatasetchanged (); Play.settext ("Start Playback"); Break; CaseMapApplication.LOCATEOVER_NOTICE_ADAPTER:adapter.notifyDataSetChanged (); //mlistview.setselection (flag); spare Break; } }};
The main logic is here, and here's a look at the effect:
Before play:
When playing:
Left-hand corresponding ListView: