android导航sdk | 百度地图api sdk-凯发k8官方旗舰厅

浏览器版本低!无法浏览完整内容,建议升级或更换浏览器。
实时导航与模拟导航
下载开发文档
生命周期

路线规划成功后可以使用专业导航服务,专业导航服务依赖app的页面生命周期,开发时,只需要将百度导航sdk专业导航生命周期接口挂接到对应页面的生命周期接口即可,app页面既可以是activity,也可以是fragment。生命周期如下:

/**
* 获取百度专业导航过程view对象,将其加入应用布局内即可显示导航过程.
*/
viewoncreate(final fragmentactivity activity, final bnguideconfig config);
/**
* 百度专业导航生命周期onstart,在{@linkplain activity#onstart()} 或者 {@linkplain fragment#onstart()} 中调用
*/
voidonstart();
/**
* 百度专业导航生命周期onresume,在{@linkplain activity#onresume()} 或者 {@linkplain fragment#onresume()} 中调用
*/
voidonresume();
/**
* 百度专业导航生命周期onpause,在{@linkplain activity#onpause()} 或者 {@linkplain fragment#onpause()} 中调用
*/
voidonpause();
/**
* 百度专业导航生命周期onstop,在{@linkplain activity#onstop()} 或者 {@linkplain fragment#onstop()} 中调用
*/
voidonstop();
/**
* 百度专业导航生命周期oondestroy,在{@linkplain activity#ondestroy()} 或者 {@linkplain fragment#ondestroy()} 中调用
*
* @param isswitchtolightnavi 在退出专业导航后是否切换到轻导航
*/
voidondestroy(boolean isswitchtolightnavi);
主要接口和参数

专业导航oncreate方法bnguideconfig参数

/**
* @param params 定制化导航参数
* @param abovebottomview 添加工具箱上方自定义view
* @param bottombarview 添加工具箱自定义view
* @param belowbottomview 添加最底部自定义view
*/
privatebnguideconfig(bundle params,
ibnrouteguidemanager.naviaddviewcallback abovebottomview,
ibnrouteguidemanager.naviaddviewcallback bottombarview,
ibnrouteguidemanager.naviaddviewcallback belowbottomview){
this.params= params;
this.abovebottomview= abovebottomview;
this.bottombarview= bottombarview;
this.belowbottomview= belowbottomview;
}

其中naviaddviewcallback参数表示可以在专业导航界面添加自定义view,bundle可以传入一些参数来自定义导航。示例如下:

bundle bundle =newbundle();
bundle.putboolean(bnavicommonparams.proguidekey.add_map,false);
bundle.putboolean(bnavicommonparams.proguidekey.is_support_full_screen,supportfullscreen());
bnguideconfig config =newbnguideconfig.builder()
// 导航工具栏上方view
.addabovebottomview(newibnrouteguidemanager.naviaddviewcallback(){
@override
public int getviewheight(){
return100;
}
@override
publicviewgetaddedview(){
textview textview =newtextview(bndemocustomguideactivity.this);
textview.setbackgroundcolor(color.parsecolor("#ffff00"));
textview.settext("导航工具栏上方自定义空间");
textview.setgravity(gravity.center);
textview.settextcolor(color.parsecolor("#000000"));
framelayout.layoutparams lp =newframelayout.layoutparams(
viewgroup.layoutparams.match_parent,100);
textview.setlayoutparams(lp);
return textview;
}
})
// 导航工具栏view
.addbottombarview(newibnrouteguidemanager.naviaddviewcallback(){
@override
publicviewgetaddedview(){
textview textview =newtextview(bndemocustomguideactivity.this);
textview.setbackgroundcolor(color.parsecolor("#ff00ff"));
textview.settext("导航工具栏自定义空间");
textview.setgravity(gravity.center);
textview.settextcolor(color.parsecolor("#000000"));
framelayout.layoutparams lp =newframelayout.layoutparams(
viewgroup.layoutparams.match_parent,viewgroup.layoutparams.match_parent);
textview.setlayoutparams(lp);
return textview;
}
})
// 导航工具栏下方view
.addbelowbottomview(newibnrouteguidemanager.naviaddviewcallback(){
@override
public int getviewheight(){
return100;
}
@override
publicviewgetaddedview(){
textview textview =newtextview(bndemocustomguideactivity.this);
textview.setbackgroundcolor(color.parsecolor("#00ffff"));
textview.settext("导航工具栏下方自定义空间");
textview.setgravity(gravity.center);
textview.settextcolor(color.parsecolor("#000000"));
framelayout.layoutparams lp =newframelayout.layoutparams(
viewgroup.layoutparams.match_parent,100);
textview.setlayoutparams(lp);
return textview;
}
})
.params(params)
.build();
baidunavimanagerfactory.getrouteguidemanager().oncreate(getactivity(), config);

导航中视图监听接口

/**
* 设置导航视图监听
* @param listener
*/
voidsetnaviviewlistener(ibnaviviewlistener listener);

导航中视图回调如下:

/**
* 诱导面板的点击事件
*/
publicvoidonmaininfopanclick(){
}
/**
* 界面左上角转向操作的点击回调
*/
publicvoidonnaviturnclick(){
}
/**
* 全览按钮的点击回调
*/
publicvoidonfullviewbuttonclick(boolean show){
}
/**
* 全览小窗口的点击
*/
publicvoidonfullviewwindowclick(boolean show){
}
/**
* 导航底部退出按钮点击后的回调接口
*/
publicvoidonnavibackclick(){
}
/**
* 底部中间部分点击事件
*/
publicvoidonbottombarclick(action action){
}
/**
* 底部设置按钮点击的回调接口
*/
publicvoidonnavisettingclick(){
}
/**
* 刷新按钮的回调接口
*/
publicvoidonrefreshbtnclick(){
}
/**
* 地图缩放等级的回调
*/
publicvoidonzoomlevelchange(int level){
}
/**
* 地图点击的回调(国测局gcj02坐标)
*/
publicvoidonmapclicked(double x, double y){
}
/**
* 移动地图的回调
*/
publicvoidonmapmoved(){
}
/**
* 后台诱导悬浮窗的点击
*/
publicvoidonfloatviewclicked(){
}

主辅路切换

/**
* 返回主辅路桥上下类型
*/
int getmainsidebridgetype();
/**
* 切换主辅路/高架桥
* @param type {@link bnavicommonparams.bnmainsidebridge}
* @param listener 只会返回onsuccess/onfail
*/
voidchangeroutebymainsidebridge(int type,changeroutelistener listener);

修改终点重算路

/**
* 导航中修改终点重新算路并导航
* @param newendnode
* @return
*/
boolean resetendnodeinnavi(bnrouteplannode newendnode);

添加途经点

/**
* 添加途经点
*/
voidaddvianodes(list<bnrouteplannode> nodes);
/**
* 设置最大途径点数量
*/
baidunavimanagerfactory.getcommonsettingmanager().setviapointcount(10)
模拟导航

与专业导航实现基本一致,区别在于导航的oncreate方法中传入需要模拟导航的参数。

bundle bundle =newbundle();
// is_realnavi代表导航类型,true表示真实导航,false表示模拟导航,默认是true
bundle.putboolean(bnavicommonparams.proguidekey.is_realnavi,false);
bnguideconfig config =newbnguideconfig.builder()
.params(params)
.build();
baidunavimanagerfactory.getrouteguidemanager().oncreate(this, config);

上一篇

算路准确性

下一篇

智能巡检

本篇文章对您是否有帮助?

网站地图