How to display multiple navigation routes on a map

Source: Internet
Author: User

How to display multiple navigation routes on a map

Case study: How many road maps are there when driving a car to Baidu building in Tiananmen District, Beijing?

Package COM. android. android_baidu_mystranit; import COM. baidu. mapapi. bmapmanager; import COM. baidu. mapapi. geopoint; import COM. baidu. mapapi. mkaddrinfo; import COM. baidu. mapapi. mkbuslineresult; import COM. baidu. mapapi. mkdrivingrouteresult; import COM. baidu. mapapi. mkgenerallistener; import COM. baidu. mapapi. mkplannode; import COM. baidu. mapapi. mkpoiresult; import COM. baidu. mapapi. mksearch; import COM. baidu. mapap I. mksearchlistener; import COM. baidu. mapapi. mksuggestionresult; import COM. baidu. mapapi. mktransitrouteresult; import COM. baidu. mapapi. mkwalkingrouteresult; import COM. baidu. mapapi. mapactivity; import COM. baidu. mapapi. mapview; import COM. baidu. mapapi. transitoverlay; import android. OS. bundle; import android. widget. toast; public class mainactivity extends mapactivity {// Add the control private mapview related to Baidu map; // The engine for loading the map is private bmapmanager. // The key private string keystring = "8c426377b3526b6bf3672c9ba3bb544d1e8289cd" of Baidu map "; // Private mksearch is used for location search, peripheral search, range search, public transport search, driving and walking search. // you can specify a start point, private mkplannode start, and private mkplannode end; @ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); mapview = (mapview) This. findviewbyid (R. id. bmapview); bmapmanager = new bmapmanager (mainactivity. this); // The Key bmapmanager must be loaded. init (keystring, new mkgenerallistener () {public void ongetpermissionstate (INT arg0) {} public void ongetnetworkstate (INT arg0) {If (arg0 = 300) {toast. maketext (mainactivity. this, "The entered key is incorrect. Please verify it !! ", 1 ). show () ;}}); this. initmapactivity (bmapmanager); // The Query Class mksearch = new mksearch (); mksearch. init (bmapmanager, new mysearchlistener (); // create a coordinate for the start point: Start = new mkplannode (); start.pt = new geopoint (INT) (39.915*1e6 ), (INT) (116.404*1e6); End = new mkplannode (); end.pt = new geopoint (40057031,2017307852); mksearch. transitsearch ("Beijing", start, end);} public class mysearchlistener implements Mksearchlistener {public void ongetaddrresult (mkaddrinfo arg0, int arg1) {// todo auto-generated method stub} public void ongetbusdetailresult (mkbuslineresult arg0, int arg1) {// todo auto-generated method stub} public void initialize (mkdrivingrouteresult arg0, int arg1) {// todo auto-generated method stub} public void ongetpoiresult (mkpoiresult result, int type, int ierror ){ // Todo auto-generated method stub} public void ongetrgc1_urlresult (string arg0, int arg1) {// todo auto-generated method stub} public void initialize (mksuggestionresult arg0, int arg1) {// todo auto-generated method stub} public void ongettransitrouteresult (mktransitrouteresult arg0, int arg1) {// todo auto-generated method stub if (arg0 = NULL) {return ;} int plannum = arg0.ge Tnumplan (); // obtain all the driving routes for (INT I = 0; I <plannum; I ++) {transitoverlay overlay = new transitoverlay (mainactivity. this, mapview); overlay. setdata (arg0.getplan (I); mapview. getoverlays (). add (overlay);} mapview. invalidate (); // refresh the map mapview. getcontroller (). animateto (arg0.getstart (). pt);} public void ongetwalkingrouteresult (mkwalkingrouteresult arg0, int arg1) {// todo auto-generated method stub} @ o Verride protected void ondestroy () {super. ondestroy (); If (bmapmanager! = NULL) {bmapmanager. Destroy (); bmapmanager = NULL ;}@override protected void onresume () {super. onresume (); If (bmapmanager! = NULL) {bmapmanager. Start () ;}@ override protected void onpause () {super. onpause (); If (bmapmanager! = NULL) {bmapmanager. Stop () ;}@ override protected Boolean isroutedisplayed () {return false ;}}

 

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.