private void StartBaidu() { // 构建 导航参数 // 天安门坐标 double mLat1 = mLatitude; double mLon1 = mLatitude; // 百度大厦坐标 double mLat2 = mLatitude2; double mLon2 = mLatitude2; LatLng pt1 = new LatLng(mLat1, mLon1); LatLng pt2 = new LatLng(mLat2, mLon2); // 构建 route搜索参数(百度地图demo) // 自己写的 NaviParaOption para = new NaviParaOption().startPoint(pt1).endPoint(pt2); // .startName(myLocation).endName(endaddress); try { // 调起百度地图步行导航 BaiduMapNavigation.openBaiduMapWalkNavi(para, this); } catch (Exception e) { e.printStackTrace(); showDialog(); } }
public static void openBaiduMapGuide(LatLng sll, LatLng ell, Context context) { // 构建 导航参数 NaviParaOption para = new NaviParaOption(); para.startPoint(sll); para.startName("从这里开始"); para.endPoint(ell); para.endName("到这里结束"); BaiduMapNavigation.openBaiduMapNavi(para, context); }
/** 调用百度地图客户端导航 */ private void startNaviByClient() { double mLat1 = userLoc.getLatitude(); double mLon1 = userLoc.getLongitude(); double mLat2 = destLoc.getLatitude(); double mLon2 = destLoc.getLongitude(); LatLng p1 = new LatLng(mLat1, mLon1); LatLng p2 = new LatLng(mLat2, mLon2); final NaviParaOption para = new NaviParaOption(); para.startPoint(p1); para.startName("起点"); para.endPoint(p2); para.endName("终点"); try { BaiduMapNavigation.openBaiduMapNavi(para, this); } catch (BaiduMapAppNotSupportNaviException e) { e.printStackTrace(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("您尚未安装百度地图app或app版本过低,点击确认安装?"); builder.setTitle("提示"); builder.setPositiveButton( "确认", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub dialog.dismiss(); BaiduMapNavigation.openWebBaiduMapNavi(para, NavigateActivity.this); } }); builder.setNegativeButton( "取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub dialog.dismiss(); } }); builder.create().show(); } }
/** * 开始导航 * * @param view */ public void startNavi() { try { LatLng pt1 = new LatLng(myX, myY); // (hotelY+0.01,hotelX+0.01); Log.e("myY-myX", myY + "---" + myX); LatLng pt2 = new LatLng(hotelY, hotelX); // 构建 导航参数 NaviPara para = new NaviPara(); para.startPoint = pt1; para.startName = "从这里开始"; para.endPoint = pt2; para.endName = "到这里结束"; try { BaiduMapNavigation.openBaiduMapNavi(para, this); } catch (BaiduMapAppNotSupportNaviException e) { e.printStackTrace(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("您尚未安装百度地图app或app版本过低,点击确认安装?"); builder.setTitle("提示"); builder.setPositiveButton( "确认", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { dialog.dismiss(); BaiduMapNavigation.getLatestBaiduMapApp(ActivityHotelLocation.this); } catch (Exception e) { e.printStackTrace(); } } }); builder.setNegativeButton( "取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); } } catch (Exception e) { e.printStackTrace(); } }