Demo entry 6417651

123123

   

Submitted by 12312312 on May 25, 2017 at 18:35
Language: Java. Code size: 1.5 kB.

//实现AMapHudView生命周期@Overrideprotected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //获取AMapNavi实例
    mAMapNavi = AMapNavi.getInstance(getApplicationContext());
    //添加监听
    mAMapNavi.addAMapNaviListener(this);

    mAMapHudView = (AMapHudView) findViewById(R.id.hudview);
    mAMapHudView.setHudViewListener(this);
}
@Overrideprotected void onResume() {
    super.onResume();
    mAMapHudView.onResume();
}
@Overrideprotected void onPause() {
    super.onPause();
    mAMapHudView.onPause();
}
@Overrideprotected void onDestroy() {
    super.onDestroy();
    mAMapHudView.onDestroy();
}
//导航初始化成功,进行路径规划@Overridepublic void onInitNaviSuccess() {
	/**
	 * 方法: int strategy=mAMapNavi.strategyConvert(congestion, avoidhightspeed, cost, hightspeed, multipleroute); 参数:
	 *
	 * @congestion 躲避拥堵
	 * @avoidhightspeed 不走高速
	 * @cost 避免收费
	 * @hightspeed 高速优先
	 * @multipleroute 多路径
	 *
	 *  说明: 以上参数都是boolean类型,其中multipleroute参数表示是否多条路线,如果为true则此策略会算出多条路线。
	 *  注意: 不走高速与高速优先不能同时为true 高速优先与避免收费不能同时为true
	 */
	int strategy = 0;
	try {
		//再次强调,最后一个参数为true时代表多路径,否则代表单路径
		strategy = mAMapNavi.strategyConvert(true, false, false, false, false);
	} catch (Exception e) {
		e.printStackTrace();
	}
	mAMapNavi.calculateDriveRoute(sList, eList, mWayPointList, strategy);
}
//算路成功回调,开始导航@Overridepublic void onCalculateRouteSuccess() {
	mAMapNavi.startNavi(NaviType.EMULATOR);
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).