005 go to the android project of mobile development (Baidu map: how to display multiple navigation routes on the map)

Source: Internet
Author: User

Please note thatArticlePlease indicate the source when Reprinting

Http://blog.csdn.net/shuaiyinoo》thank you


When writing this blog, you need to first note that multiple navigation lines are displayed on the map, whether for a walking line or a driving route, or public transportation routes are also applicable.

The implementation of this multiple lines is only a little different from that of a display, but only adds a loop. Let's take a look.

The specific implementation is as follows:

The first step is to add the following content to the oncreate method like the previous blogs.Code

// Search mapcontroller for Multiple Route entries at v9.00. setzoom (14); // search for objects within the MAP range mksearch = new mksearch (); mksearch. init (bmapmanager, new mysearchlistener (); // specify the first coordinate start = new mkplannode (); start.pt = new geopoint (INT) (39.915*1e6), (INT) (116.404*1e6); // specify the Second coordinate end = new mkplannode (); end.pt = new geopoint (40057031,2017307852); // call the route callback method mksearch. transitsearch ("Beijing", start, end );

The following method is implemented in the interface implemented by mysearchlistener implements mksearchlistener:

@ Overridepublic void ongettransitrouteresult (mktransitrouteresult result, int type) {// callback Method for Public Transit transfer // v7.00 // If (result = NULL) {// return; /// transitoverlay = new transitoverlay (baidu_suyiactivity.this, mapview); // transitoverlay. setdata (result. getplan (0); // mapview. getoverlays (). add (transitoverlay); // refresh the map // mapview. invalidate (); // v9.00if (result = NULL) {return ;}// obtain all driving routes. Int plannum = result. getnumplan (); For (INT I = 0; I <plannum; I ++) {transitoverlay = new transitoverlay (baidu_suyiactivity.this, mapview); transitoverlay. setdata (result. getplan (I); mapview. getoverlays (). add (transitoverlay);} mapview. invalidate (); mapview. getcontroller (). animateto (result. getstart (). pt );}

The above method compares and does not use the v7.00 and v9.00 methods. You will find that there is only one more loop, in this example, do I know how to display multiple entries in other methods?

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.