Search in sources :

Example 1 with TMC

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();
    }
}
Also used : DriveStep(com.amap.api.services.route.DriveStep) TMC(com.amap.api.services.route.TMC) LatLonPoint(com.amap.api.services.core.LatLonPoint)

Example 2 with TMC

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);
}
Also used : ArrayList(java.util.ArrayList) TMC(com.amap.api.services.route.TMC) LatLonPoint(com.amap.api.services.core.LatLonPoint) LatLonPoint(com.amap.api.services.core.LatLonPoint) PolylineOptions(com.amap.api.maps.model.PolylineOptions)

Example 3 with TMC

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());
        }
    }
}
Also used : DriveStep(com.amap.api.services.route.DriveStep) Intent(android.content.Intent) TMC(com.amap.api.services.route.TMC)

Aggregations

TMC (com.amap.api.services.route.TMC)3 LatLonPoint (com.amap.api.services.core.LatLonPoint)2 DriveStep (com.amap.api.services.route.DriveStep)2 Intent (android.content.Intent)1 PolylineOptions (com.amap.api.maps.model.PolylineOptions)1 ArrayList (java.util.ArrayList)1