use of com.amap.api.services.route.TMC in project LivingInCampus by DulCoder.
the class DrivingRouteOverlay method addToMap.
/**
* 添加驾车路线添加到地图上显示。
*/
public void addToMap() {
initPolylineOptions();
try {
if (mAMap == null) {
return;
}
if (mWidth == 0 || drivePath == null) {
return;
}
mLatLngOfPath = new ArrayList<>();
tmcs = new ArrayList<>();
List<DriveStep> drivePaths = drivePath.getSteps();
mPolylineOptions.add(startPoint);
for (DriveStep step : drivePaths) {
List<LatLonPoint> latLonPoints = step.getPolyline();
List<TMC> tmcList = step.getTMCs();
tmcs.addAll(tmcList);
addDrivingStationMarkers(step, convertToLatLng(latLonPoints.get(0)));
for (LatLonPoint latlonpoint : latLonPoints) {
mPolylineOptions.add(convertToLatLng(latlonpoint));
mLatLngOfPath.add(convertToLatLng(latlonpoint));
}
}
mPolylineOptions.add(endPoint);
if (startMarker != null) {
startMarker.remove();
startMarker = null;
}
if (endMarker != null) {
endMarker.remove();
endMarker = null;
}
addStartAndEndMarker();
addThroughPointMarker();
if (isColorFulLine && tmcs.size() > 0) {
colorWayUpdate(tmcs);
showColorPolyline();
} else {
showPolyline();
}
} catch (Throwable e) {
e.printStackTrace();
}
}
use of com.amap.api.services.route.TMC in project LivingInCampus by DulCoder.
the class DrivingRouteOverlay method colorWayUpdate.
/**
* 根据不同的路段拥堵情况展示不同的颜色
*
* @param tmcSection
*/
private void colorWayUpdate(List<TMC> tmcSection) {
if (mAMap == null) {
return;
}
if (tmcSection == null || tmcSection.size() <= 0) {
return;
}
TMC segmentTrafficStatus;
mPolylineOptionsColor = null;
mPolylineOptionsColor = new PolylineOptions();
mPolylineOptionsColor.width(getRouteWidth());
List<Integer> colorList = new ArrayList<Integer>();
mPolylineOptionsColor.add(startPoint);
mPolylineOptionsColor.add(AMapUtil.convertToLatLng(tmcSection.get(0).getPolyline().get(0)));
colorList.add(getDriveColor());
for (int i = 0; i < tmcSection.size(); i++) {
segmentTrafficStatus = tmcSection.get(i);
int color = getColor(segmentTrafficStatus.getStatus());
List<LatLonPoint> mPolyline = segmentTrafficStatus.getPolyline();
for (int j = 1; j < mPolyline.size(); j++) {
mPolylineOptionsColor.add(AMapUtil.convertToLatLng(mPolyline.get(j)));
colorList.add(color);
}
}
mPolylineOptionsColor.add(endPoint);
colorList.add(getDriveColor());
mPolylineOptionsColor.colorValues(colorList);
}
use of com.amap.api.services.route.TMC in project LivingInCampus by DulCoder.
the class DriveRouteDetailActivity method getIntentData.
private void getIntentData() {
Intent intent = getIntent();
if (intent == null) {
return;
}
mDrivePath = intent.getParcelableExtra("drive_path");
mDriveRouteResult = intent.getParcelableExtra("drive_result");
for (int i = 0; i < mDrivePath.getSteps().size(); i++) {
DriveStep step = mDrivePath.getSteps().get(i);
List<TMC> tmclist = step.getTMCs();
for (int j = 0; j < tmclist.size(); j++) {
String s = "" + tmclist.get(j).getPolyline().size();
Log.i("MY", s + tmclist.get(j).getStatus() + tmclist.get(j).getDistance() + tmclist.get(j).getPolyline().toString());
}
}
}
Aggregations