ios - 高德地图sdk导航AMapNaviKit中的路径规划的路线naviRoute始终为空
PHP中文网
PHP中文网 2017-04-17 17:52:53
[iOS讨论组]

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

[_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];
}

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

PHP中文网
PHP中文网

认证0级讲师

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号