Android Baidu Map SDK navigation SDK2.0 combined with positioning SDK6.0.5 navigation parameter setting method

Source: Internet
Author: User

A period of time before the content of Baidu map, but also the future and summary, and soon some problems and solutions have forgotten, now record the more tangled problems, share the following

Title, now the navigation SDK2.0 of the navigation initiator function is as follows

        public boolean launchnavigator (activity activity,                               java.util.list<bnrouteplannode> nodes,                               int Preference,                               boolean isgpsnav,                               Baidunavimanager.routeplanlistener Listener)

The parameters given in the document are interpreted as follows:

Parameters:
activity -Recommendation is the main activity of the app
nodes -Incoming calculation nodes, which are the starting point, pass point, and end point, with a maximum of three passes, refer to Bnrouteplannode
preference -Road preference, reference routeplanpreference definition
isGPSNav -True indicates real GPS navigation, false indicates simulated navigation
listener -Start the navigation callback listener, which is usually the navigation process page.
Return:
Whether the execution succeeds in the node for the calculation, now has a new rule, visible Bnrouteplannode

The interpretation of the document is as follows:

Public Bnrouteplannode (double longitude,                       double latitude,                       java.lang.String name,                       java.lang.String Description,                       bnrouteplannode.coordinatetype coType)
A method for constructing a route node.
Parameters:
longitude -Longitude
latitude -Latitude
name -Count the road node name
description -Calculate the path node address description
coType -coordinate type, reference Coordinatetype
As you can see, there is now a standard for the coordinate type of the routing node, i.e.

BD09_MCBaidu Mercator coordinates
GCJ02Coordinates of the National Bureau of Surveying
WGS84GPS coordinates
The coordinate type must be above three, otherwise it will cause the calculation to fail if you do not specify or the default match of these three coordinate types.


However, the coordinate system of the Baidu positioning SDK is generally used BD09LL type, this time need to use the type conversion, before the 5.3 version can have another method to convert, but 5.3 version is canceled, so 6.0.5 after this function to do the conversion, as follows
Public static bdlocation getbdlocationincoortype (bdlocation src,
java.lang.String TransferType)
bdlocation in the corresponding coordinate system according to the set conversion coordinate system type
Parameters:
BDLOCATION-SRC Original Bdlocation
transfertype-bdlocation.bdlocation_gcj02_to_bd09/bdlocation_gcj02_to_bd09ll/bdlocation_bd09_to_gcj02/ BDLOCATION_BD09LL_TO_GCJ02
with this you can direct Baidu positioning and map to get the Bdlocation converted to direct use of navigation parameters.

In this hope can help to still do not understand how to convert the classmate!

Some of the code is as follows:

//initiates the calculation of private void Startcalcroute (int calcmode) {//Display Load dialog box Dialogutil.getinstance (). Showprogressdialog (mactivity), if (mbdlocation = = null) {Toast.maketext (this, getString (r.string.map_location_failed ), Toast.length_long). Show ();//Cancel Load Dialog dialogutil.getinstance (). Dismissprogressdialog (); return;}  if (Calcmode = = 0) Calcmode = baidunavimanager.routeplanpreference.route_plan_mod_avoid_tafficjam;double SX = 0, SY = 0, EX = 0, EY = 0;SX = Locationclient.getbdlocationincoortype (mbdlocation, bdlocation.bdlocation_bd09ll_to_gcj02). Getlatitude (); SY = Locationclient.getbdlocationincoortype (mbdlocation, bdlocation.bdlocation_bd09ll_to_gcj02). Getlongitude (); Bnrouteplannode startnode = new Bnrouteplannode (SY, SX, "My Location", "my Location"); 
bdlocation bd = new bdlocation (); Bd.setlatitude (Destlat); Bd.setlongitude (DESTLNG); EX = Locationclient.getbdlocationincoortype (BD, bdlocation.bdlocation_bd09ll_to_gcj02). GetLatitude (); EY = Locationclient.getbdlocationincoortype (BD, bdlocation.bdlocation_bd09ll_to_gcj02). GetLongitude (); Bnrouteplannode Endnode = new Bnrouteplannode (EY, EX, strdestaddress, strdestaddress); arraylist<bnrouteplannode> nodeList = new arraylist<bnrouteplannode> (2); Nodelist.add (StartNode); Nodelist.add (Endnode); Baidunavimanager.getinstance (). Launchnavigator (Mactivity, NodeList, Calcmode, True,new Maprouteplanlistener ( Startnode));}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Baidu Map SDK navigation SDK2.0 combined with positioning SDK6.0.5 navigation parameter setting method

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.