com.amap.api.services.route.TMC Java Examples
The following examples show how to use
com.amap.api.services.route.TMC.
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: DriveRouteDetailActivity.java From TraceByAmap with MIT License | 6 votes |
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()); } } }
Example #2
Source File: DrivingRoutePlanOverlay.java From TraceByAmap with MIT License | 4 votes |
/** * 添加驾车路线添加到地图上显示。 */ public void addToMap() { initPolylineOptions(); try { if (mAMap == null) { return; } if (mWidth == 0 || driveRoutePlanResult == null) { return; } if (driveRoutePlanResult.getTimeInfos() == null || driveRoutePlanResult.getPaths() == null) { return; } mLatLngsOfPath = new ArrayList<LatLng>(); List<TMC> tmcs = new ArrayList<TMC>(); List<TimeInfo> timeInfos = driveRoutePlanResult.getTimeInfos(); if (selectIndex >= 0 && selectIndex < timeInfos.size()) { tmcs = timeInfos.get(selectIndex).getElements().get(0).getTMCs(); } int pathIndex = timeInfos.get(selectIndex).getElements().get(0).getPathindex(); if (pathIndex < 0 || pathIndex > driveRoutePlanResult.getPaths().size()) { return; } DrivePlanPath drivePlanPath = driveRoutePlanResult.getPaths().get(pathIndex); List<DrivePlanStep> drivePaths = drivePlanPath.getSteps(); for (DrivePlanStep step : drivePaths) { List<LatLonPoint> latlonPoints = step.getPolyline(); //List<TMC> tmclist = step.getTMCs(); //tmcs.addAll(tmclist); for (LatLonPoint latlonpoint : latlonPoints) { mPolylineOptions.add(convertToLatLng(latlonpoint)); mLatLngsOfPath.add(convertToLatLng(latlonpoint)); } } if (startMarker != null) { startMarker.remove(); startMarker = null; } if (endMarker != null) { endMarker.remove(); endMarker = null; } addStartAndEndMarker(); if (isColorfulline && tmcs.size()>0 ) { colorWayUpdate(tmcs); showcolorPolyline(); }else { showPolyline(); } } catch (Throwable e) { e.printStackTrace(); } }
Example #3
Source File: TruckRouteColorfulOverLay.java From TraceByAmap with MIT License | 4 votes |
/** * 添加驾车路线添加到地图上显示。 */ public void addToMap() { initPolylineOptions(); try { if (mAMap == null) { return; } if (mWidth == 0 || truckPath == null) { return; } mLatLngsOfPath = new ArrayList<LatLng>(); tmcs = new ArrayList<TMC>(); List<TruckStep> steps = truckPath.getSteps(); for (TruckStep step : steps) { List<LatLonPoint> latlonPoints = step.getPolyline(); List<TMC> tmclist = step.getTMCs(); tmcs.addAll(tmclist); for (LatLonPoint latlonpoint : latlonPoints) { mPolylineOptions.add(convertToLatLng(latlonpoint)); mLatLngsOfPath.add(convertToLatLng(latlonpoint)); } } if (startMarker != null) { startMarker.remove(); startMarker = null; } if (endMarker != null) { endMarker.remove(); endMarker = null; } addStartAndEndMarker(); addThroughPointMarker(); if (isColorfulline && tmcs.size()>0 ) { colorWayUpdate(tmcs); }else { showPolyline(); } } catch (Throwable e) { e.printStackTrace(); } }
Example #4
Source File: TruckRouteColorfulOverLay.java From TraceByAmap with MIT License | 4 votes |
/** * 根据不同的路段拥堵情况展示不同的颜色 * * @param tmcSection */ private void colorWayUpdate(List<TMC> tmcSection) { if (mAMap == null) { return; } if (mLatLngsOfPath == null || mLatLngsOfPath.size() <= 0) { return; } if (tmcSection == null || tmcSection.size() <= 0) { return; } int j = 0; LatLng startLatLng = mLatLngsOfPath.get(0); LatLng endLatLng = null; double segmentTotalDistance = 0; TMC segmentTrafficStatus; List<LatLng> tempList = new ArrayList<LatLng>(); //画出起点到规划路径之间的连线 addPolyLine(new PolylineOptions().add(startPoint, startLatLng) .setDottedLine(true)); //终点和规划路径之间连线 addPolyLine(new PolylineOptions().add(mLatLngsOfPath.get(mLatLngsOfPath.size()-1), endPoint).setDottedLine(true)); for (int i = 0; i < mLatLngsOfPath.size() && j < tmcSection.size(); i++) { segmentTrafficStatus = tmcSection.get(j); endLatLng = mLatLngsOfPath.get(i); double distanceBetweenTwoPosition = calculateDistance(startLatLng, endLatLng); segmentTotalDistance = segmentTotalDistance + distanceBetweenTwoPosition; if (segmentTotalDistance > segmentTrafficStatus.getDistance() + 1) { double toSegDis = distanceBetweenTwoPosition - (segmentTotalDistance - segmentTrafficStatus.getDistance()); LatLng middleLatLng = getPointForDis(startLatLng, endLatLng, toSegDis); tempList.add(middleLatLng); startLatLng = middleLatLng; i--; } else { tempList.add(endLatLng); startLatLng = endLatLng; } if (segmentTotalDistance >= segmentTrafficStatus.getDistance() || i == mLatLngsOfPath.size() - 1) { if (j == tmcSection.size() - 1 && i < mLatLngsOfPath.size() - 1) { for (i++; i < mLatLngsOfPath.size(); i++) { LatLng lastLatLng = mLatLngsOfPath.get(i); tempList.add(lastLatLng); } } j++; if (segmentTrafficStatus.getStatus().equals("畅通")) { addPolyLine((new PolylineOptions()).addAll(tempList) .width(mWidth).color(Color.GREEN)); } else if (segmentTrafficStatus.getStatus().equals("缓行")) { addPolyLine((new PolylineOptions()).addAll(tempList) .width(mWidth).color(Color.YELLOW)); } else if (segmentTrafficStatus.getStatus().equals("拥堵")) { addPolyLine((new PolylineOptions()).addAll(tempList) .width(mWidth).color(Color.RED)); } else if (segmentTrafficStatus.getStatus().equals("严重拥堵")) { addPolyLine((new PolylineOptions()).addAll(tempList) .width(mWidth).color(Color.parseColor("#990033"))); } else { addPolyLine((new PolylineOptions()).addAll(tempList) .width(mWidth).color(Color.parseColor("#537edc"))); } tempList.clear(); tempList.add(startLatLng); segmentTotalDistance = 0; } if (i == mLatLngsOfPath.size() - 1) { addPolyLine(new PolylineOptions().add(endLatLng, endPoint) .setDottedLine(true)); } } }
Example #5
Source File: DrivingRouteOverlay.java From TraceByAmap with MIT License | 4 votes |
/** * 添加驾车路线添加到地图上显示。 */ public void addToMap() { initPolylineOptions(); try { if (mAMap == null) { return; } if (mWidth == 0 || drivePath == null) { return; } mLatLngsOfPath = new ArrayList<LatLng>(); tmcs = new ArrayList<TMC>(); List<DriveStep> drivePaths = drivePath.getSteps(); 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)); mLatLngsOfPath.add(convertToLatLng(latlonpoint)); } } 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(); } }
Example #6
Source File: DrivingRouteOverlay.java From BmapLite with GNU General Public License v3.0 | 4 votes |
/** * 添加驾车路线添加到地图上显示。 */ public void addToMap() { initPolylineOptions(); try { if (mAMap == null) { return; } if (getRouteWidth() == 0 || drivePath == null) { return; } mLatLngsOfPath = new ArrayList<LatLng>(); tmcs = new ArrayList<TMC>(); 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)); mLatLngsOfPath.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(); } }
Example #7
Source File: DrivingRouteOverlay.java From BmapLite with Apache License 2.0 | 4 votes |
/** * 添加驾车路线添加到地图上显示。 */ public void addToMap() { initPolylineOptions(); try { if (mAMap == null) { return; } if (getRouteWidth() == 0 || drivePath == null) { return; } mLatLngsOfPath = new ArrayList<LatLng>(); tmcs = new ArrayList<TMC>(); 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)); mLatLngsOfPath.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(); } }