Before you have encountered this problem, is to draw a distance between two points, and then display the line in the visual range, the following are some of the main code:
#pragma mark-Drive route Search-(void) Ongetdrivingrouteresult: (bmkroutesearch*) Searcher Result: (bmkdrivingrouteresult*) Result ErrorCode: (Bmksearcherrorcode) error{if (Error = = Bmk_search_no_error) {//This handles normal results nsarray* array = [Nsarray arraywitharray:_mapview.annotations]; [_mapview Removeannotations:array]; Array = [Nsarray arraywitharray:_mapview.overlays]; [_mapview Removeoverlays:array]; if (Error = = bmk_search_no_error) {bmkdrivingrouteline* plan = (bmkdrivingrouteline*) [Result.routes objectatin DEX:0]; Calculates the number of road segments in the route scheme int size = [Plan.steps count]; int planpointcounts = 0; for (int i = 0; i < size; i++) {bmkdrivingstep* transitstep = [Plan.steps objectatindex:i]; if (i==0) {routeannotation* item = [[Routeannotation alloc]init]; Item.coordinate = plan.starting.location; Item.title = @ "starting point"; Item.type = 0; [_mapview Addannotation:item]; Add Start Callout}else if (i==size-1) {routeannotation* item = [[Routeannota tion Alloc]init]; Item.coordinate = plan.terminal.location; Item.title = @ "End point"; Item.type = 1; [_mapview Addannotation:item]; Add a start callout}//Add annotation node routeannotation* item = [[Routeannotation alloc] INIT]; Item.coordinate = transitStep.entrace.location; Item.title = transitstep.entraceinstruction; Item.degree = transitstep.direction * 30; Item.type = 4; [_mapview Addannotation:item]; Total number of locus points cumulative planpointcounts + = Transitstep.pointscount; -----------------------------------------------------------if (i==0) { The initial value of the first sitting punctuation Minlat = plan.starting.location.latitude; Maxlat = Plan.starting.location.latitude; Minlon = Plan.starting.location.longitude; Maxlon = Plan.starting.location.longitude; }else{//Contrast filters out minimum latitude, maximum latitude, minimum longitude, maximum longitude Minlat = min (Minlat, transitStep.entrace.location.la Titude); Maxlat = MAX (Maxlat, transitStep.entrace.location.latitude); Minlon = MIN (Minlon, transitStep.entrace.location.longitude); Maxlon = MAX (Maxlon, transitStep.entrace.location.longitude); } //----------------------------------------------------------- } [Self setvisibleregin]; Add via point if (plan.waypoints) {for (bmkplannode* Tempnode in plan.waypoints) { routeannotation* itEM = [[Routeannotation alloc]init]; item = [[Routeannotation alloc]init]; Item.coordinate = tempnode.pt; Item.type = 5; Item.title = Tempnode.name; [_mapview Addannotation:item]; }}//Locus point bmkmappoint * temppoints = new bmkmappoint[planpointcounts]; int i = 0; for (int j = 0; J < size; J + +) {bmkdrivingstep* transitstep = [Plan.steps objectatindex:j]; int k=0; for (k=0;k<transitstep.pointscount;k++) {temppoints[i].x = transitstep.points[k].x; Temppoints[i].y = TRANSITSTEP.POINTS[K].Y; i++; }}//Build Bmkpolyline bmkpolyline* polyLine by points = [Bmkpoly Line Polylinewithpoints:temppoints count:planpointcounts]; [_mapview Addoverlay:polyLine]; Add route overlay Delete []temppoints; }} else {NSLog (@ "Sorry, no results found"); }}
-(void) setvisibleregin{ //center point cllocationcoordinate2d Centcoor; Centcoor.latitude = (cllocationdegrees) ((maxlat+minlat) * 0.5f); Centcoor.longitude = (cllocationdegrees) ((maxlon+minlon) * 0.5f); Bmkcoordinatespan span; Calculates the span of a geographic location Span.latitudedelta = Maxlat-minlat; Span.longitudedelta = Maxlon-minlon; The coordinates of the data are derived bmkcoordinateregion region = Bmkcoordinateregionmake (Centcoor, span); The coordinate range of the Baidu map is converted to the relative view of the location cgrect fitrect = [_mapview convertregion:region torecttoview:_mapview]; Converts the location of the map view to the location of the map, bmkmaprect fitmaprect = [_mapview convertrect:fitrect tomaprectfromview:_mapview]; Set the map visual range to the map location where the data resides [_mapview setvisiblemaprect:fitmaprect animated:yes];}
Welcome everyone to criticize!!!
Dynamic visual display of IOS map lines