IOS development based on Baidu map (4) -- path search

Source: Internet
Author: User
Tags polyline

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

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.