Search in sources :

Example 1 with RouteBusWalkItem

use of com.amap.api.services.route.RouteBusWalkItem 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)

Aggregations

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