我按照官方文档上路径规划的方法,将两个固定坐标传入方法:
[_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];
}
这使得我无法获得路径信息,从而无法在地图上绘制折线。求解。