Android's handling of track playback on Baidu Map

Source: Internet
Author: User
Tags sendmsg

I. Requirements

In order to depict a person's historical trajectory over a period of time on a map and play back the trajectory in chronological order.

2. Nagging

Baidu map has its own APIs for tracking and Line tracing, and everyone should be there. There are certainly more than one method for playing animations. If you have a good method, share it with us, the younger brother is grateful.

Iii. Description

My method is: In a thread, after playing the video, traverse the list that stores the item, find the current item, remove its marker, and change it to a marker, add it to the list, and then sleep. Then, judge what the current item looks like if it is not the current item, so that iteration can be done.

I'm a newbie, but the code quality is not high. Do not spray it. Thank you.

The main snippets are as follows:

1. Main Logic

/** Track playback logic processing **/private runnable rz = new runnable () {@ overridepublic synchronized void run () {While (isstartrun) {for (INT I = 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 = minflater. inflate (R. layout. overlay_item, null); textview useritemtv1 = (textview) view. findviewbyid (R. id. item_tv1); US Eritemtv1.settext (index + 1 + ""); bitmap BMP = userlocateutil. createnewbitmap (View); drawable = new bitmapdrawable (BMP); item. setmarker (drawable);} If (! Isbcak) {break;} moverlaygraphic. additem (item); mmapview. Refresh (); index ++; If (! Isfinish) {Index = 0; sendmsg (mapapplication. locateover_play_finish); break ;}}}}};

2. Operation Processing

/** Track playback **/private void playtrajecener () {play. setonclicklistener (New onclicklistener () {@ overridepublic void onclick (view v) {If (! "Start playback ". equals (play. gettext (). tostring () {isstartrun = false; isbcak = false; play. settext ("start playback");} else {play. settext ("pause playback"); isfinish = true; isstartrun = true; isbcak = true; thread = new thread (RZ); If (! Thread. isalive () {thread. Start ();}}}});}

3. UI Processing

Private handler = new handler () {public void handlemessage (Message MSG) {Switch (MSG. what) {Case mapapplication. locateover_change_mapview: changemapview (); break; Case mapapplication. locate_mapview_refresh: mmapview. refresh (); mmapview. getcontroller (). zoomtospan (moverlaygraphic. getlatspane6 (), moverlaygraphic. getlonspane6 (); mmapview. getcontroller (). setcenter (moverlaygraphic. getcenter (); pocprogressdialog. cancel (); break; Case mapapplication. locateover_play_finish: Toast. maketext (mainactivity. mainactivity, "playing completed", toast. length_short ). show (); flag = 99999; adapter. notifydatasetchanged (); play. settext ("start playback"); break; Case mapapplication. locateover_notice_adapter: adapter. notifydatasetchanged (); // mlistview. setselection (FLAG); standby break ;}}};

Finally, there is no picture, no truth ,;










Related Article

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.