コード例 #1
0
  /** @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);
        }
      }
    }
  }
コード例 #2
0
 private void addBusLineSteps(List<LatLonPoint> listPoints) {
   if (listPoints.size() < 1) {
     return;
   }
   addPolyLine(
       new PolylineOptions()
           .width(getRouteWidth())
           .color(getBusColor())
           .addAll(AMapUtil.convertArrList(listPoints)));
 }