关于高德地图在iOS中调用骑行导航

       高德地图在其SDK中提供了单独的骑行路线规划https://lbs.amap.com/api/ios-navi-sdk/guide/route-plan/ride-route-plan,但是没有提供骑行导航的相关,导航只有驾车实时导航https://lbs.amap.com/api/ios-navi-sdk/guide/navigation-map/gps。

SDK中实时导航时可以进行不同的路线规划,这块又跳到各自的路径规划页面,或者串联不起来。高德给的demo中也没有骑行导航的相关示例,网上也查不到相关有用的信息,所以只能自己深入查看SDK,发现如果想要实现在移动端的骑行导航,步骤如下:

1、获取起始点和终点的经纬度坐标

- (void)initProperties
{
    self.startPoint = [AMapNaviPoint locationWithLatitude:39.99 longitude:116.47];
    self.endPoint   = [AMapNaviPoint locationWithLatitude:39.90 longitude:116.32];
}

2、引入骑行导航界面AMapNaviRideView

- (void)initDriveView
{
    if (self.driveView == nil)
    {
        self.driveView = [[AMapNaviRideView alloc] initWithFrame:self.view.bounds];
        self.driveView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
        [self.driveView setDelegate:self];

        [self.driveView setTrackingMode:AMapNaviViewTrackingModeMapNorth];
        
        [self.view addSubview:self.driveView];
    }
}

3、引入骑行管理类

- (void)initRideManager
{
    if (!self.rideManager)
    {
        self.rideManager = [[AMapNaviRideManager alloc] init];
        [self.rideManager setDelegate:self];

        [self.rideManager addDataRepresentative:self.driveView];
        
    }
}

4、进行路径规划

  [self.rideManager calculateRideRouteWithStartPoint:self.startPoint
                                              endPoint:self.endPoint];

5、路径规划成功后的delegete回调处理

/**
 * @brief 骑行路径规划成功后的回调函数
 * @param rideManager 骑行导航管理类
 */
- (void)rideManagerOnCalculateRouteSuccess:(AMapNaviRideManager *)rideManager{
    //算路成功后开始GPS导航
    [rideManager startGPSNavi];
}

 

希望能够帮助到有需要的同学们,有问题可以评论,看到会回复。

你可能感兴趣的:(iOS开发)