浏览器版本低!无法浏览完整内容,建议升级或更换浏览器。

文档全面上新

更科技的视觉体验,更高效的页面结构,快前往体验吧!

体验新版
第3行: 第3行:
 
     <div class="title-hd">出行场景的多路线规划</div><!-- 标题下子标题及简介,可有多个 -->
 
     <div class="title-hd">出行场景的多路线规划</div><!-- 标题下子标题及简介,可有多个 -->
 
     <div class="title-mi">使用场景</div>
 
     <div class="title-mi">使用场景</div>
     <div class="wrap-mi"></div><!--  -->
+
     <div class="wrap-mi">根据起终点规划多条路线,结合路线特点,帮助用户选择合适路线。</div><!--  -->
 
</div>
 
</div>
 
<div class="demos_wrap">
 
<div class="demos_wrap">
 
     <div class="header">
 
     <div class="header">
 
         <div class="andiord-header active">Android</div>
 
         <div class="andiord-header active">Android</div>
         <div class="ios-header hide">iOS</div>
+
         <div class="ios-header">iOS</div>
 
     </div>
 
     </div>
 
     <div class="andiord-wrap wrap">
 
     <div class="andiord-wrap wrap">
第190行: 第190行:
 
         </div>
 
         </div>
 
         <div class="pre-nav">
 
         <div class="pre-nav">
             <div>一定要再BaiduNaviManagerFactory.getBaiduNaviManager().init 完成,并且回调initSuccess后,在初始化语音播报引擎以及进行routePlan算路</div>
+
             <div>一定要在BaiduNaviManagerFactory.getBaiduNaviManager().init 完成,并且回调initSuccess后,再初始化语音播报引擎以及进行routePlan算路。</div>
 
         </div>
 
         </div>
 
        
 
        
第323行: 第323行:
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
 
                                 <div>
 
                                 <div>
                                     <div class="table-wrap-className">BMKClusterManager</div>
+
                                     <div class="table-wrap-className">BMKMultiRouteSelectedView</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>- (void)clearClusterItems;</div>
+
                                     <div>- (void)configData:(NSArray<BNCarOneRouteModel *> *)routes</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>清除标注集群items</div>
+
                                     <div>配置路线数据</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>V4.0.0起</div>
+
                                     <div></div>
 
                                 </div>
 
                                 </div>
 
      
 
      
第338行: 第338行:
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
 
                                 <div>
 
                                 <div>
                                     <div class="table-wrap-className">BMKClusterManager</div>
+
                                     <div class="table-wrap-className">BMKMultiRouteSelectedView</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>- (NSArray&lt;BMKCluster *&gt; *)getClusters:(CGFloat)zoomLevel;</div>
+
                                     <div>- (void)multiRouteSelected:(NSUInteger)index;</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>根据地图缩放级别获取标注集群</div>
+
                                     <div>设置选中第几条route</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>V4.0.0起</div>
+
                                    <div></div>
 +
                                </div>
 +
                            </div>
 +
                            <div class="table_wrap_w">
 +
                                <div>
 +
                                    <div class="table-wrap-className">BMKMultiRouteSelectedView</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>- (void)routeSelected:(void(^)(NSUInteger index))selectedBlock;</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>方案选中回调</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div></div>
 +
                                </div>
 +
                            </div>
 +
                            <div class="table_wrap_w">
 +
                                <div>
 +
                                    <div class="table-wrap-className">BNaviService</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>- (void)startNaviRoutePlan:(BNRoutePlanMode)eMode naviNodes:(NSArray*)naviNodes time:(BNaviCalcRouteTime*)naviTime delegete:(id<BNNaviRoutePlanDelegate>)delegate userInfo:(NSDictionary*)userInfo</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>发起算路</div>
 +
                                </div>
 +
                                <div>
 +
                                     <div>V4.8.0起</div>
 +
                                </div>
 +
                            </div>
 +
                            <div class="table_wrap_w">
 +
                                <div>
 +
                                    <div class="table-wrap-className">BNaviService</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>- (void)routePlanDidFinished:(NSDictionary*)userInfo;</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>算路成功回调</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>V4.8.0起</div>
 +
                                </div>
 +
                            </div>
 +
                            <div class="table_wrap_w">
 +
                                <div>
 +
                                    <div class="table-wrap-className">BNaviService</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>- (void)routePlanDidFailedWithError:(NSError *)error andUserInfo:(NSDictionary*)userInfo;</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>算路失败回调</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>V4.8.0起</div>
 +
                                </div>
 +
                            </div>
 +
                            <div class="table_wrap_w">
 +
                                <div>
 +
                                    <div class="table-wrap-className">BNaviService</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>-(void)routePlanDidUserCanceled:(NSDictionary*)userInfo;</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>算路取消回调</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>V4.8.0起</div>
 +
                                </div>
 +
                            </div>
 +
                            <div class="table_wrap_w">
 +
                                <div>
 +
                                    <div class="table-wrap-className">BNaviService</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>- (void)onHandleTouchRouteAtIndex:(NSUInteger)routeIndex;</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>用户在地图上点击了某条路线回调</div>
 +
                                </div>
 +
                                <div>
 +
                                    <div>V4.8.0起</div>
 
                                 </div>
 
                                 </div>
   
 
 
                             </div>
 
                             </div>
                           
 
  
 
                         </div>
 
                         </div>
第364行: 第446行:
 
         </div>
 
         </div>
 
         <div class="pre-wrap">
 
         <div class="pre-wrap">
            <div class="pre-wrap-title">1.第一步</div>
 
 
             <div class="pre-wrap-nav">
 
             <div class="pre-wrap-nav">
 
                 <div>Objective-C</div>
 
                 <div>Objective-C</div>
第372行: 第453行:
 
                 <!-- ios示例代码位置 -->
 
                 <!-- ios示例代码位置 -->
 
                 <pre class="prettyprint prettyprinted pre-ios">
 
                 <pre class="prettyprint prettyprinted pre-ios">
1
+
/** 发起算路. */
/** 更新标注展示. */
+
- (void)startRoutePlan {
- (void)updateClusters {
+
     if (self.nodes.count >= 2) {
_clusterZoom = (NSInteger)_mapView.zoomLevel;
+
         BNaviService_RoutePlan.disableOpenUrl = YES;
@synchronized(_clusterManager.clusterCaches) {
+
         [BNaviService_RoutePlan startNaviRoutePlan:BNRoutePlanMode_Recommend naviNodes:self.nodes time:nil delegete:self userInfo:nil];
    NSMutableArray *clusters = [_clusterManager.clusterCaches objectAtIndex:(_clusterZoom - 3)];
+
     if (clusters.count > 0) {
+
 
+
         // 移除一组标注
+
        [_mapView removeAnnotations:_mapView.annotations];
+
        //将一组标注添加到当前地图View中
+
        [_mapView addAnnotations:clusters];
+
    } else {
+
    __weak typeof(self) weakSelf = self;
+
         dispatch_async(dispatch_get_global_queue(0, 0), ^{
+
            // 获取聚合后的标注
+
            __block NSArray *array = [weakSelf.clusterManager getClusters:weakSelf.clusterZoom];
+
            dispatch_async(dispatch_get_main_queue(), ^{
+
                for (BMKCluster *item in array) {
+
                    ClusterAnnotation *annotation = [[ClusterAnnotation alloc] init];
+
                    // 设置标注的经纬度坐标
+
                    annotation.coordinate = item.coordinate;
+
                    annotation.size = item.size;
+
                    // 设置标注的标题
+
                    annotation.title = [NSString stringWithFormat:@"我是%lu个", (unsigned long)item.size];
+
                    [clusters addObject:annotation];
+
                }
+
                // 移除一组标注
+
                [weakSelf.mapView removeAnnotations:weakSelf.mapView.annotations];
+
                // 将一组标注添加到当前地图View中
+
                [weakSelf.mapView addAnnotations:clusters];
+
            });
+
        });
+
 
     }
 
     }
 
}
 
}
 +
/** 屏幕适配. */
 +
- (void)showRouteViewAll {
 +
    BNMargin margin = {80, 20, CGRectGetHeight(self.view.frame) - (KScreenHeight-[self bottomPaneHeight]-(kRAButtonHeight*2+1)-5), 20};
 +
    [BNaviService_DriveRoute showRouteViewAll:margin animated:YES];
 
}
 
}
 
+
#pragma mark - BNNaviRoutePlanDelegate
                </pre>
+
/** 算路成功回调. */
                <div class="pre-btn">
+
- (void)routePlanDidFinished:(NSDictionary*)userInfo {
                    <div class="pre-btn-copy-ios">复制</div>
+
    NSLog(@"算路成功回调 = %@", userInfo);
                    <div class="pre-btn-cb-ios">深色</div>
+
     [self showRouteViewAll];
                </div>
+
    [self initMapSubView];
                <div class="success">复制成功</div>
+
     BNCarRouteModel *route = userInfo[BNDriveRouteDataKey];
            </div>
+
    if (route) {
        </div>
+
        self.carRoute = route;
        <div class="pre-wrap">
+
            <div class="pre-wrap-title">2.第二步</div>
+
            <div class="pre-wrap-nav">
+
                <div>Objective-C</div>
+
            </div>
+
           
+
            <div class="pre-wrap-w pre-wrap-w-ios code_container">
+
                <!-- ios示例代码位置 -->
+
                <pre class="prettyprint prettyprinted pre-ios">
+
2
+
/** 更新标注展示. */
+
- (void)updateClusters {
+
_clusterZoom = (NSInteger)_mapView.zoomLevel;
+
@synchronized(_clusterManager.clusterCaches) {
+
    NSMutableArray *clusters = [_clusterManager.clusterCaches objectAtIndex:(_clusterZoom - 3)];
+
     if (clusters.count > 0) {
+
 
+
        // 移除一组标注
+
        [_mapView removeAnnotations:_mapView.annotations];
+
        //将一组标注添加到当前地图View中
+
        [_mapView addAnnotations:clusters];
+
     } else {
+
    __weak typeof(self) weakSelf = self;
+
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
+
            // 获取聚合后的标注
+
            __block NSArray *array = [weakSelf.clusterManager getClusters:weakSelf.clusterZoom];
+
            dispatch_async(dispatch_get_main_queue(), ^{
+
                for (BMKCluster *item in array) {
+
                    ClusterAnnotation *annotation = [[ClusterAnnotation alloc] init];
+
                    // 设置标注的经纬度坐标
+
                    annotation.coordinate = item.coordinate;
+
                    annotation.size = item.size;
+
                    // 设置标注的标题
+
                    annotation.title = [NSString stringWithFormat:@"我是%lu个", (unsigned long)item.size];
+
                    [clusters addObject:annotation];
+
                }
+
                // 移除一组标注
+
                [weakSelf.mapView removeAnnotations:weakSelf.mapView.annotations];
+
                // 将一组标注添加到当前地图View中
+
                [weakSelf.mapView addAnnotations:clusters];
+
            });
+
        });
+
 
     }
 
     }
}
+
    // 配置路线数据
}
+
    [self.multiRouteView configData:self.carRoute.carRoutes];
 
+
     // 默认选中第一条
                </pre>
+
    [self.multiRouteView multiRouteSelected:0];
                <div class="pre-btn">
+
   
                    <div class="pre-btn-copy-ios">复制</div>
+
    // 路线选中回调
                    <div class="pre-btn-cb-ios">深色</div>
+
                </div>
+
                <div class="success">复制成功</div>
+
            </div>
+
        </div>
+
        <div class="pre-wrap">
+
            <div class="pre-wrap-title">3.名字</div>
+
            <div class="pre-wrap-nav">
+
                <div>Objective-C</div>
+
            </div>
+
           
+
            <div class="pre-wrap-w pre-wrap-w-ios code_container">
+
                <!-- ios示例代码位置 -->
+
                <pre class="prettyprint prettyprinted pre-ios">
+
3
+
/** 更新标注展示. */
+
- (void)updateClusters {
+
_clusterZoom = (NSInteger)_mapView.zoomLevel;
+
@synchronized(_clusterManager.clusterCaches) {
+
    NSMutableArray *clusters = [_clusterManager.clusterCaches objectAtIndex:(_clusterZoom - 3)];
+
     if (clusters.count > 0) {
+
 
+
        // 移除一组标注
+
        [_mapView removeAnnotations:_mapView.annotations];
+
        //将一组标注添加到当前地图View中
+
        [_mapView addAnnotations:clusters];
+
    } else {
+
 
     __weak typeof(self) weakSelf = self;
 
     __weak typeof(self) weakSelf = self;
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
+
    [self.multiRouteView routeSelected:^(NSUInteger index) {
            // 获取聚合后的标注
+
        [weakSelf routeSelectIndex:index needSelectRoute:YES];
            __block NSArray *array = [weakSelf.clusterManager getClusters:weakSelf.clusterZoom];
+
    }];
            dispatch_async(dispatch_get_main_queue(), ^{
+
                for (BMKCluster *item in array) {
+
                    ClusterAnnotation *annotation = [[ClusterAnnotation alloc] init];
+
                    // 设置标注的经纬度坐标
+
                    annotation.coordinate = item.coordinate;
+
                    annotation.size = item.size;
+
                    // 设置标注的标题
+
                    annotation.title = [NSString stringWithFormat:@"我是%lu个", (unsigned long)item.size];
+
                    [clusters addObject:annotation];
+
                }
+
                // 移除一组标注
+
                [weakSelf.mapView removeAnnotations:weakSelf.mapView.annotations];
+
                // 将一组标注添加到当前地图View中
+
                [weakSelf.mapView addAnnotations:clusters];
+
            });
+
        });
+
    }
+
 
}
 
}
}
 
 
 
                 </pre>
 
                 </pre>
 
                 <div class="pre-btn">
 
                 <div class="pre-btn">
第525行: 第494行:
 
             </div>
 
             </div>
 
         </div>
 
         </div>
 +
     
 
         <div class="more-nav">
 
         <div class="more-nav">
 
             <div class="left-icon"></div>
 
             <div class="left-icon"></div>

2020年6月1日 (一) 12:01的版本

出行场景的多路线规划
使用场景
根据起终点规划多条路线,结合路线特点,帮助用户选择合适路线。
Android
iOS

                        
1590746640|//mapopen-website-wiki.bj.bcebos.com/demos/qrcodes/多路线.png
扫码体验
使用产品
产品1|/index.php?title=test
>
产品2|/index.php?title=test
下载源码
//mapopen-pub-androidsdk.cdn.bcebos.com/map/sample/BaiduLBS_AndroidSDK_Sample.zip
核心接口
接口
描述
BaiduNaviManagerFactory
getBaiduNaviManager()
获取导航管理类实例
BaiduNaviManagerFactory
getMapManager()
获取基础地图管理类示例
BaiduNaviManagerFactory
getTTSManager()
获取语音播放管理类实例
BaiduNaviManagerFactory
getRoutePlanManager()
获取路径规划类实例
BaiduNaviManagerFactory
getRouteGuideManager()
获取导航管理类实例
IBNMapManager
attach(ViewGroup viewGroup);
地图底图attach到ViewGroup
IBNMapManager
detach(ViewGroup viewGroup)
地图地图从ViewGroup detach
IBaiduNaviManager
init(Context context, String dataDir,String appFolderName, INaviInitListener listener)
导航初始化接口
IBNTTSManager
initTTS(Context context, String sdcardDir, String appFolderName, String ttsAppID);
初始化语音播报引擎
IBNRoutePlanManager
routeplan(List<BNRoutePlanNode> var1, int var2, Bundle var3, Handler var4);
进行算路


重点关注
一定要在BaiduNaviManagerFactory.getBaiduNaviManager().init 完成,并且回调initSuccess后,再初始化语音播报引擎以及进行routePlan算路。


核心代码
JAVA
/**
* 算路规划
*
* @param sNode
* @param eNode
*/
private void routePlan(BNRoutePlanNode sNode, BNRoutePlanNode eNode) {
    List<BNRoutePlanNode> list = new ArrayList<>();
    list.add(sNode);
    list.add(eNode);

    BaiduNaviManagerFactory.getRoutePlanManager().routeplan(
            list,
            IBNRoutePlanManager.RoutePlanPreference.ROUTE_PLAN_PREFERENCE_DEFAULT,
            null,
            new Handler(Looper.getMainLooper()) {
                @Override
                public void handleMessage(Message msg) {
                    switch (msg.what) {
                        case IBNRoutePlanManager.MSG_NAVI_ROUTE_PLAN_START:
                            Log.d(TAG, "算路开始!");
                            break;
                        case IBNRoutePlanManager.MSG_NAVI_ROUTE_PLAN_SUCCESS:
                            Log.d(TAG, "成功!");
                            mFl_retry.setVisibility(View.GONE);

                            FragmentManager fm = getSupportFragmentManager();
                            FragmentTransaction tx = fm.beginTransaction();
                            DemoRouteResultFragment fragment = new DemoRouteResultFragment();
                            tx.add(R.id.fragment_content, fragment, "RouteResult");
                            tx.commit();
                            break;
                        case IBNRoutePlanManager.MSG_NAVI_ROUTE_PLAN_FAILED:
                            mFl_retry.setVisibility(View.VISIBLE);
                            Toast.makeText(getApplicationContext(),
                                    "算路失败", Toast.LENGTH_SHORT).show();
                            break;
                        default:
                            // nothing
                            break;
                    }
                }
            });
}
}              
                
复制
深色
复制成功



  • 文档根本没法用

  • 文档水平很差

  • 文档水平一般

  • 文档不错

  • 文档写的很好

如发现文档错误,或对此文档有更好的建议,请在下方反馈。问题咨询请前往反馈平台提交工单咨询。

提交反馈

拖动标注工具

添加矩形标注

添加箭头标注

完成

取消