IOS Baidu map track record road fitting

Source: Internet
Author: User
Tags polyline

IOS Baidu map track record road fitting

Recently, I am working on a small demo to try track records.

The recording track must be constantly retrieved and recorded to the database.

During the discount, the link will be directly connected at the corner of the road and will not fit with the road. Here I will talk about my solution.

I called the path planning api of Baidu map. In this way, the path fitting function can be realized.

Add dome here: Click to open the link

Note: This dome is running on a real machine and an error will be reported on the simulator. Pay attention when downloading.

For various reasons, images are taken on mobile phones.

Take a look at the previous figure:

VcTHteO1xM/crop + jrMn6s8m1xM/fwrfU2s/Cw + crop "brush: java;">-(void) skip :( BMKRouteSearch *) searcher result :( warn *) result errorCode :( BMKSearchErrorCode) errorThis is the proxy method.

BMKPlanNode * startNode = [[BMKPlanNode alloc] init]; CLLocationCoordinate2D startCoordinate; startCoordinate. latitude = 36.727558; startCoordinate. longpolling = 119.185956; startNode.pt = startCoordinate; BMKPlanNode * endNode = [[BMKPlanNode alloc] init]; CLLocationCoordinate2D endCoordnate; endCoordnate. latitude = 36.827558; endCoordnate. longdesk= 119.385956; endNode.pt = endCoordnate; BMKDrivingRoutePlanOption * drivingRoutePlanOption = [[BMKDrivingRoutePlanOption alloc] init]; drivingRoutePlanOption. from = startNode; drivingRoutePlanOption. to = endNode; if ([_ searcher drivingSearch: drivingRoutePlanOption]) {NSLog (@ "");}

-(Void) onGetDrivingRouteResult :( BMKRouteSearch *) searcher result :( failed *) result errorCode :( BMKSearchErrorCode) error {BMKDrivingRouteLine * plan = (BMKDrivingRouteLine *) [result. routes objectAtIndex: 0]; int size = (int) [plan. steps count]; int pointCount = 0; for (int I = 0; I <size; I ++) {BMKDrivingStep * step = [plan. steps objectAtIndex: I]; pointCount + = step. pointsCount;} BMKMapPoint * points = new BMKMapPoint [pointCount]; int k = 0; for (int I = 0; I <size; I ++) {BMKDrivingStep * step = [plan. steps objectAtIndex: I]; for (int j = 0; j
 
  
In the above method, we obtain the road section of the line from the returned line, obtain the points in the road section from the road section, and draw the lines for these points.
  

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.