com.amap.api.services.route.DriveRouteResult Java Examples

The following examples show how to use com.amap.api.services.route.DriveRouteResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RouteTask.java    From Android_UsingCar_Example with Apache License 2.0 6 votes vote down vote up
@Override
public void onDriveRouteSearched(DriveRouteResult driveRouteResult,
		int resultCode) {
	if (resultCode == 0 && driveRouteResult != null) {
		synchronized (this) {
			for (OnRouteCalculateListener listener : mListeners) {
				List<DrivePath> drivepaths = driveRouteResult.getPaths();
				float distance = 0;
				int duration = 0;
				if (drivepaths.size() > 0) {
					DrivePath drivepath = drivepaths.get(0);

					distance = drivepath.getDistance() / 1000;

					duration = (int) (drivepath.getDuration() / 60);
				}

				float cost = driveRouteResult.getTaxiCost();

				listener.onRouteCalculate(cost, distance, duration);
			}

		}
	}
	// TODO 可以根据app自身需求对查询错误情况进行相应的提示或者逻辑处理
}
 
Example #2
Source File: FlutterAMapSearchRegister.java    From flutter_amap_plugin with MIT License 5 votes vote down vote up
@Override
public void onDriveRouteSearched(DriveRouteResult driveRouteResult, int i) {
    if (driveRouteResult.getPaths().size() > 0) {
        DrivePath drivePath = driveRouteResult.getPaths().get(0);
        Map<String, Object> map = new HashMap<>();
        map.put("duration", drivePath.getDuration());
        map.put("distance", drivePath.getDistance());
        map.put("strategy", drivePath.getStrategy());
        map.put("totalTrafficLights", drivePath.getTotalTrafficlights());
        FlutterAmapPlugin.routeChannel.invokeMethod("onRouteSearchDone", map);
    } else {
        FlutterAmapPlugin.locChannel.invokeMethod("routePlanningError",
                "路线规划错误:{" + i + " - 未发现有效路径}");
    }
}
 
Example #3
Source File: RoutePOIActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
@Override
public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {
	dissmissProgressDialog();
	aMap.clear();// 清理地图上的所有覆盖物
	if (errorCode == AMapException.CODE_AMAP_SUCCESS) {
		if (result != null && result.getPaths() != null) {
			if (result.getPaths().size() > 0) {
				mDriveRouteResult = result;
				final DrivePath drivePath = mDriveRouteResult.getPaths()
						.get(0);
				DrivingRouteOverlay drivingRouteOverlay = new DrivingRouteOverlay(
						mContext, aMap, drivePath,
						mDriveRouteResult.getStartPos(),
						mDriveRouteResult.getTargetPos(), null);
				drivingRouteOverlay.setNodeIconVisibility(false);//设置节点marker是否显示
				drivingRouteOverlay.removeFromMap();
				drivingRouteOverlay.addToMap();
				drivingRouteOverlay.zoomToSpan();

			} else if (result != null && result.getPaths() == null) {
				ToastUtil.show(mContext, R.string.no_result);
			}

		} else {
			ToastUtil.show(mContext, R.string.no_result);
		}
	} else {
		ToastUtil.showerror(this.getApplicationContext(), errorCode);
	}
}
 
Example #4
Source File: ListLocationPlan.java    From BetterWay with Apache License 2.0 5 votes vote down vote up
@Override
public void onDriveRouteSearched(DriveRouteResult driveRouteResult, int i) {
    if (i == RIGHTCODE) {
        DrivePath drivePath = driveRouteResult.getPaths().get(0);
        RoutePlan routePlan = initAndSetRoutePlan(CAR, drivePath, (int) drivePath.getTolls());
        addPlan(driveRouteResult.getDriveQuery().getFromAndTo(), routePlan);
    }
}
 
Example #5
Source File: RouteActivity.java    From TraceByAmap with MIT License 4 votes vote down vote up
/**
 * 驾车路线搜索结果方法回调
 */
@Override
public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {
	dissmissProgressDialog();
	aMap.clear();// 清理地图上的所有覆盖物
	if (errorCode == AMapException.CODE_AMAP_SUCCESS) {
		if (result != null && result.getPaths() != null) {
			if (result.getPaths().size() > 0) {
				mDriveRouteResult = result;
				final DrivePath drivePath = mDriveRouteResult.getPaths()
						.get(0);
				if(drivePath == null) {
					return;
				}
				DrivingRouteOverlay drivingRouteOverlay = new DrivingRouteOverlay(
						mContext, aMap, drivePath,
						mDriveRouteResult.getStartPos(),
						mDriveRouteResult.getTargetPos(), null);
				drivingRouteOverlay.setNodeIconVisibility(false);//设置节点marker是否显示
				drivingRouteOverlay.setIsColorfulline(true);//是否用颜色展示交通拥堵情况,默认true
				drivingRouteOverlay.removeFromMap();
				drivingRouteOverlay.addToMap();
				drivingRouteOverlay.zoomToSpan();
				mBottomLayout.setVisibility(View.VISIBLE);
				int dis = (int) drivePath.getDistance();
				int dur = (int) drivePath.getDuration();
				String des = AMapUtil.getFriendlyTime(dur)+"("+AMapUtil.getFriendlyLength(dis)+")";
				mRotueTimeDes.setText(des);
				mRouteDetailDes.setVisibility(View.VISIBLE);
				int taxiCost = (int) mDriveRouteResult.getTaxiCost();
				mRouteDetailDes.setText("打车约"+taxiCost+"元");
				mBottomLayout.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						Intent intent = new Intent(mContext,
								DriveRouteDetailActivity.class);
						intent.putExtra("drive_path", drivePath);
						intent.putExtra("drive_result",
								mDriveRouteResult);
						startActivity(intent);
					}
				});
			} else if (result != null && result.getPaths() == null) {
				ToastUtil.show(mContext, R.string.no_result);
			}

		} else {
			ToastUtil.show(mContext, R.string.no_result);
		}
	} else {
		ToastUtil.showerror(this.getApplicationContext(), errorCode);
	}
	
	
}
 
Example #6
Source File: DriveRouteActivity.java    From TraceByAmap with MIT License 4 votes vote down vote up
@Override
public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {
	dissmissProgressDialog();
	aMap.clear();// 清理地图上的所有覆盖物
	if (errorCode == AMapException.CODE_AMAP_SUCCESS) {
		if (result != null && result.getPaths() != null) {
			if (result.getPaths().size() > 0) {
				mDriveRouteResult = result;
				final DrivePath drivePath = mDriveRouteResult.getPaths()
						.get(0);
				if(drivePath == null) {
					return;
				}
				DrivingRouteOverlay drivingRouteOverlay = new DrivingRouteOverlay(
						mContext, aMap, drivePath,
						mDriveRouteResult.getStartPos(),
						mDriveRouteResult.getTargetPos(), null);
				drivingRouteOverlay.setNodeIconVisibility(false);//设置节点marker是否显示
				drivingRouteOverlay.setIsColorfulline(true);//是否用颜色展示交通拥堵情况,默认true
				drivingRouteOverlay.removeFromMap();
				drivingRouteOverlay.addToMap();
				drivingRouteOverlay.zoomToSpan();
				mBottomLayout.setVisibility(View.VISIBLE);
				int dis = (int) drivePath.getDistance();
				int dur = (int) drivePath.getDuration();
				String des = AMapUtil.getFriendlyTime(dur)+"("+AMapUtil.getFriendlyLength(dis)+")";
				mRotueTimeDes.setText(des);
				mRouteDetailDes.setVisibility(View.VISIBLE);
				int taxiCost = (int) mDriveRouteResult.getTaxiCost();
				mRouteDetailDes.setText("打车约"+taxiCost+"元");
				mBottomLayout.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						Intent intent = new Intent(mContext,
								DriveRouteDetailActivity.class);
						intent.putExtra("drive_path", drivePath);
						intent.putExtra("drive_result",
								mDriveRouteResult);
						startActivity(intent);
					}
				});
				
			} else if (result != null && result.getPaths() == null) {
				ToastUtil.show(mContext, R.string.no_result);
			}

		} else {
			ToastUtil.show(mContext, R.string.no_result);
		}
	} else {
		ToastUtil.showerror(this.getApplicationContext(), errorCode);
	}
	
	
}
 
Example #7
Source File: RideRouteActivity.java    From TraceByAmap with MIT License 2 votes vote down vote up
@Override
public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {
	
}
 
Example #8
Source File: WalkRouteActivity.java    From TraceByAmap with MIT License 2 votes vote down vote up
@Override
public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {
	
}
 
Example #9
Source File: BusRouteActivity.java    From TraceByAmap with MIT License 2 votes vote down vote up
@Override
public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {
	
}
 
Example #10
Source File: AmapBusFragment.java    From BmapLite with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {

}
 
Example #11
Source File: AmapBusFragment.java    From BmapLite with Apache License 2.0 2 votes vote down vote up
@Override
public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {

}