Search in sources :

Example 1 with WalkStep

use of com.amap.api.services.route.WalkStep in project LivingInCampus by DulCoder.

the class BusRouteOverlay method addWalkSteps.

/**
 * @param busStep
 */
private void addWalkSteps(BusStep busStep) {
    RouteBusWalkItem routeBusWalkItem = busStep.getWalk();
    List<WalkStep> walkSteps = routeBusWalkItem.getSteps();
    for (int j = 0; j < walkSteps.size(); j++) {
        WalkStep walkStep = walkSteps.get(j);
        if (j == 0) {
            LatLng latLng = AMapUtil.convertToLatLng(walkStep.getPolyline().get(0));
            // 道路名字
            String road = walkStep.getRoad();
            // 步行导航信息
            String instruction = getWalkSnippet(walkSteps);
            addWalkStationMarkers(latLng, road, instruction);
        }
        List<LatLng> listWalkPolyline = AMapUtil.convertArrList(walkStep.getPolyline());
        this.latLng = listWalkPolyline.get(listWalkPolyline.size() - 1);
        addWalkPolyline(listWalkPolyline);
        // 假如步行前一段的终点和下的起点有断开,断画直线连接起来,避免断线问题
        if (j < walkSteps.size() - 1) {
            LatLng lastLatLng = listWalkPolyline.get(listWalkPolyline.size() - 1);
            LatLng firstlatLatLng = AMapUtil.convertToLatLng(walkSteps.get(j + 1).getPolyline().get(0));
            if (!(lastLatLng.equals(firstlatLatLng))) {
                addWalkPolyline(lastLatLng, firstlatLatLng);
            }
        }
    }
}
Also used : RouteBusWalkItem(com.amap.api.services.route.RouteBusWalkItem) LatLng(com.amap.api.maps.model.LatLng) WalkStep(com.amap.api.services.route.WalkStep) LatLonPoint(com.amap.api.services.core.LatLonPoint)

Example 2 with WalkStep

use of com.amap.api.services.route.WalkStep in project LivingInCampus by DulCoder.

the class BusRouteOverlay method getLastWalkPoint.

/**
 * @param busStep
 * @return
 */
private LatLonPoint getLastWalkPoint(BusStep busStep) {
    List<WalkStep> walkSteps = busStep.getWalk().getSteps();
    WalkStep walkStep = walkSteps.get(walkSteps.size() - 1);
    List<LatLonPoint> lonPoints = walkStep.getPolyline();
    return lonPoints.get(lonPoints.size() - 1);
}
Also used : WalkStep(com.amap.api.services.route.WalkStep) LatLonPoint(com.amap.api.services.core.LatLonPoint)

Example 3 with WalkStep

use of com.amap.api.services.route.WalkStep in project LivingInCampus by DulCoder.

the class WalkRouteOverlay method addToMap.

/**
 * 添加步行路线到地图中。
 * @since V2.1.0
 */
public void addToMap() {
    initPolylineOptions();
    try {
        List<WalkStep> walkPaths = walkPath.getSteps();
        mPolylineOptions.add(startPoint);
        for (int i = 0; i < walkPaths.size(); i++) {
            WalkStep walkStep = walkPaths.get(i);
            LatLng latLng = AMapServicesUtil.convertToLatLng(walkStep.getPolyline().get(0));
            addWalkStationMarkers(walkStep, latLng);
            addWalkPolyLines(walkStep);
        }
        mPolylineOptions.add(endPoint);
        addStartAndEndMarker();
        showPolyline();
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : LatLng(com.amap.api.maps.model.LatLng) WalkStep(com.amap.api.services.route.WalkStep) LatLonPoint(com.amap.api.services.core.LatLonPoint)

Example 4 with WalkStep

use of com.amap.api.services.route.WalkStep in project LivingInCampus by DulCoder.

the class WalkSegmentListAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null) {
        holder = new ViewHolder();
        convertView = View.inflate(mContext, R.layout.item_bus_segment, null);
        holder.lineName = (TextView) convertView.findViewById(R.id.bus_line_name);
        holder.dirIcon = (ImageView) convertView.findViewById(R.id.bus_dir_icon);
        holder.dirUp = (ImageView) convertView.findViewById(R.id.bus_dir_icon_up);
        holder.dirDown = (ImageView) convertView.findViewById(R.id.bus_dir_icon_down);
        holder.splitLine = (ImageView) convertView.findViewById(R.id.bus_seg_split_line);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    final WalkStep item = mItemList.get(position);
    if (position == 0) {
        holder.dirIcon.setImageResource(R.drawable.dir_start);
        holder.lineName.setText("出发");
        holder.dirUp.setVisibility(View.INVISIBLE);
        holder.dirDown.setVisibility(View.VISIBLE);
        holder.splitLine.setVisibility(View.INVISIBLE);
        return convertView;
    } else if (position == mItemList.size() - 1) {
        holder.dirIcon.setImageResource(R.drawable.dir_end);
        holder.lineName.setText("到达终点");
        holder.dirUp.setVisibility(View.VISIBLE);
        holder.dirDown.setVisibility(View.INVISIBLE);
        return convertView;
    } else {
        holder.splitLine.setVisibility(View.VISIBLE);
        holder.dirUp.setVisibility(View.VISIBLE);
        holder.dirDown.setVisibility(View.VISIBLE);
        String actionName = item.getAction();
        int resID = AMapUtil.getWalkActionID(actionName);
        holder.dirIcon.setImageResource(resID);
        holder.lineName.setText(item.getInstruction());
        return convertView;
    }
}
Also used : WalkStep(com.amap.api.services.route.WalkStep)

Aggregations

WalkStep (com.amap.api.services.route.WalkStep)4 LatLonPoint (com.amap.api.services.core.LatLonPoint)3 LatLng (com.amap.api.maps.model.LatLng)2 RouteBusWalkItem (com.amap.api.services.route.RouteBusWalkItem)1