routePlanningPage static method

void routePlanningPage({
  1. required List<MLatLng> wayPoints,
  2. int? drivingMode,
  3. PlanningCallBack? callBack,
  4. CalculateCallBack? calculateBack,
})

新增 线路规划 带自动分页 wayPoints>6时

Implementation

static void routePlanningPage({required List<MLatLng> wayPoints, int? drivingMode, PlanningCallBack? callBack,CalculateCallBack? calculateBack}) {
  if (wayPoints.length < 2) return;
  XbrAmapSearch.routeSearchPage(
    wayPoints: wayPoints,
    drivingMode: drivingMode ?? DrivingMode.DRIVING_SINGLE_DEFAULT,
    back: (code, data) {
      if (code != 1000) {
        ToLatLng southwest, northeast;
        if (wayPoints[0].latitude < wayPoints[0].latitude) {
          southwest = ToLatLng.from(wayPoints[0]);
          northeast = ToLatLng.from(wayPoints[1]);
        } else {
          southwest = ToLatLng.from(wayPoints[1]);
          northeast = ToLatLng.from(wayPoints[0]);
        }
        if (callBack != null) callBack((code), [], LatLngBounds(southwest: southwest, northeast: northeast));
        return;
      }
      if(data.paths==null|| data.paths!.isEmpty) return;
      List<LatLng> points = PointUtil.listCover(data.paths![0].polyline);
      if (callBack != null) {
        callBack(1000, points, PointUtil.lineBounds(points));
      }
      if(calculateBack != null){
        calculateBack(data.paths![0].distance?.toInt()??0,data.paths![0].duration?.toInt()??0);
      }
    },
  );
}