BMKWalkNavigationManager *manager = [BMKWalkNavigationManager sharedManager];BMKWalkNaviViewController *controller = [[BMKWalkNaviViewController alloc] init];controller.navigationType = 0;BOOL inited = [[BMKWalkNavigationManager sharedManager] initNaviEngine:controller option:[self dispalyOption]];
/// 设置是否支持多路线规划选择,可在routePlanDelegate回调中处理多路线并进行绘制选择。默认NO@property (nonatomic, assign) BOOL enableMultiRoute;
/// 多路线规划代理回调@property (nonatomic, weak) id <BMKWalkCycleRoutePlanDelegate> routePlanDelegate;
BMKWalkNaviLaunchParam
BMKWalkNaviRouteNodeInfo
nodeInfo只有BMKWalkNavigationRouteNodeKeyword起终点支持多路线)
BMKWalkNaviRouteNodeInfo *startNode = [[BMKWalkNaviRouteNodeInfo alloc] init];startNode.location = self.startAnnotation.coordinate;startNode.keyword = @"百度大厦";startNode.type = BMKWalkNavigationRouteNodeKeyword;BMKWalkNaviRouteNodeInfo *endNode = [[BMKWalkNaviRouteNodeInfo alloc] init];endNode.location = self.endAnnotation.coordinate;endNode.keyword = @"百度科技园";BMKWalkNaviLaunchParam *param = [[BMKWalkNaviLaunchParam alloc] init];param.startNode = startNode;param.endNode = endNode;
[[BMKWalkNavigationManager sharedManager] routePlanWithParams:param];
- (void)onRoutePlanResult:(BMKWalkCycleRoutePlanErrorCode)errorCode naviType:(BMKWalkCycleNavigationType)naviType{}
6.1 获取多路线信息
BMKWalkNavigationManager/// 获取导航多路线规划信息 since 6.6.2/// 需要在算路规划成功(-onRoutePlanResult: naviType:)后获取,否则会为nil- (NSArray<BMKWalkCycleRouteResult *> *)getWalkNaviMulRouteInfos;
路线信息包含:路线总长度,路线总耗时,红绿灯个数,路段所经过的坐标集合(经纬度点转成的NSValue,经纬度坐标系与全局坐标系对应[BMKMapManager getCoordinateTypeUsedInBaiduMapSDK])
@interface BMKWalkCycleRouteResult : NSObject/// 路线长度 单位: 米@property (nonatomic, assign) NSUInteger distance;/// 路线耗时 单位: 秒@property (nonatomic, assign) NSUInteger duration;/// 红绿灯个数@property (nonatomic, assign) NSUInteger lightCount;/// 路段所经过的坐标集合@property (nonatomic, strong) NSArray<NSValue *> *positions;@end
6.2 绘制多路线
BMKWalkNavigationManager/// 展示步行多路线 since 6.4.0/// @param mapview 展示路线的mapView/// @return obj 路线BMKPolyline- (NSArray<BMKPolyline *> *)displayRoutePlanResult:(BMKMapView *)mapview;
BMKWalkNavigationManager/// 引擎算路接口 since 6.4.0/// @param routeIndex 路线索引- (void)naviCalcRoute:(NSInteger)routeIndex;
/// 引擎算路代理,回调成功时即可调用startWalkNaviWithParentController开始导航@property (nonatomic, weak) id <BMKWalkNaviCalcRouteDelegate> calcRouteDelegate;
- (void)onNaviCalcRouteResult:(BMKWalkCycleRoutePlanErrorCode)errorCode naviType:(BMKWalkCycleNavigationType)naviType {[[BMKWalkNavigationManager sharedManager] startWalkNaviWithParentController:self isPush:YES];}
9.1 ParentController 为nil时
a.可获取步行导航底图对象添加到任何需要的位置
/*** 获取步行导航底图对象*/- (BMKMapView *)getNaviMap;
或
b.可创建关联多实例导航View添加到任何需要的位置
BMKMultiNaviView *multiNaviView = [[BMKMultiNaviView alloc] initWithFrame:CGRectMake(0, 150, 200, 300)];multiNaviView.defaultNaviMapLevel = 19;// 多实例地图必须在算路前设置多实例导航类型并绑定数据源BOOL bindFlag = [multiNaviView bindNaviDataSourceWithNaviType:BMK_WALK_CYCLE_NAVIGATION_TYPE_WALK];if (bindFlag) {NSLog(@"SDK-多实例导航数据绑定成功");} else {NSLog(@"SDK-多对实例导航数据绑定失败");}
/**导航过程生命周期函数, 暂停导航*/- (void)pause;/**导航过程生命周期函数, 恢复导航*/- (void)resume;/**导航过程生命周期函数, 结束导航*/- (void)stop;
/**销毁单例*/+ (void)destroy;
上一篇
下一篇
本篇文章对您是否有帮助?