This article describes how to use the interface by using the left and end coordinates of the start point.
1. Search for paths
Bmksearch * search = [[bmksearch alloc] init]; // create a search object. Do not release the search object. delegate = self; // set the callback proxy for the path search result to bmkplannode * currentnode = [[bmkplannode alloc] init]; currentnode.pt = themapview. userlocation. coordinate; currentnode. name = @ "AAA"; // Note: it cannot be blank here @ "" bmkplannode * poinode = [[bmkplannode alloc] init]; poinode.pt = vehiclelocation. coordinate; poinode. name = @ "BBB"; // Note: it cannot be blank here @ "" [search drivingroutesearch: Nil startnode: currentnode endcity: Nil endnode: poinode]; // search for the driving route as an example.
2. process routes through callback of Route Search Results
-(Void) ongetdrivingrouteresult :( bmkplanresult *) Result errorcode :( INT) error {If (error = bmkerrorok) {bmkrouteplan * plan = (bmkrouteplan *) [result. plans objectatindex: 0]; bmkroute * Route = [plan. routes objectatindex: 0]; bmkmappoint * points = malloc (sizeof (cllocationcoordinate2d) * route. steps. count); For (INT I = 0; I <route. steps. count; ++ I) {bmkstep * step = [route. steps objectatindex: I]; bmkmappoint point = bmkmappointforcoordinate (step.pt); // note the processing method here: points [I] = point;} [mapview removeoverlays: [mapview overlays]; bmkpolyline * polyline = [bmkpolyline polylinewithpoints: points count: route. steps. count]; free (points); [mapview addoverlay: polyline] ;}}
3. process the display of the path in the processing path callback.
-(Bmkoverlayview *) mapview :( bmkmapview *) mapview viewforoverlay :( id <bmkoverlay>) Overlay {bmkoverlayview * result = [[[bmkpolylineview alloc] callback: overlay] autorellay]; result. strokecolor = [uicolor bluecolor]; result. linewidth = 4.0; result. linejoin = kcglinejoinround; result. linecap = kcglinecapround; return result ;}
IOS development based on Baidu map (1) -- current user location
IOS development based on Baidu map (2) -- getting poi
IOS development based on Baidu map (3) -- address search
IOS development based on Baidu map (4) -- path search
IOS development based on Baidu map (5)-Summary of core issues
IOS development based on Baidu map (6) -- Google coordinates to hundreds of coordinates
IOS development based on Baidu map (7) -- convert Baidu coordinates to Google coordinates