高德地图sdk导航AMapNaviKit中的路径规划的路线naviRoute始终为空

我按照官方文档上路径规划的方法,将两个固定坐标传入方法:

[_naviManager calculateDriveRouteWithStartPoints:startPoints endPoints:endPoints wayPoints: nil drivingStrategy: 0];

规划后也成功进入了回调函数

- (void)naviManagerOnCalculateRouteSuccess:(AMapNaviManager *)naviManager;

但是其中的naviManager里的naviRoute属性始终为空,我可以确定传入的两个点有一定的距离。

- (void)addBeginAndEndAnnotation {
    _endAnnotation = [[MAPointAnnotation alloc] init];
    CLLocationCoordinate2D coordinate = {30.655593,104.073803};
    [_endAnnotation setCoordinate:coordinate];
    _endAnnotation.title        = @"终点";
    [_mapView addAnnotation:_endAnnotation];
    _beginAnnotation = [[MAPointAnnotation alloc] init];
    CLLocationCoordinate2D coordinatebegin = {30.612339,104.071503};
    [_beginAnnotation setCoordinate:coordinatebegin];
    _beginAnnotation.title        = @"起点";
    [_mapView addAnnotation:_beginAnnotation];
    
    AMapNaviPoint *startPoint = [AMapNaviPoint locationWithLatitude:30.655593 longitude:104.073803];
    AMapNaviPoint *endPoint = [AMapNaviPoint locationWithLatitude:30.612339 longitude:104.071503];
    
    NSArray *startPoints = [[NSArray alloc] initWithObjects: startPoint, nil];
    NSArray *endPoints   = [[NSArray alloc] initWithObjects: endPoint, nil];
    //NSArray *mid = [[NSArray alloc] initWithObjects: endPoint, nil];
    
    //驾车路径规划(未设置途经点、导航策略为速度优先)
    [_naviManager calculateDriveRouteWithStartPoints:startPoints endPoints:endPoints wayPoints: nil drivingStrategy: 2];
    
    
    //步行路径规划
    // [self.naviManager calculateWalkRouteWithStartPoints:startPoints endPoints:endPoints];
}

这使得我无法获得路径信息,从而无法在地图上绘制折线。求解

图片描述

阅读 6.4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题