Android to play the historical track on Baidu map

Source: Internet
Author: User
Tags sendmsg

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.