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 ,;