routeSearch static method

Future<void> routeSearch({
  1. required List<LatLng> wayPoints,
  2. int? strategy,
  3. int? showFields = ShowFields.POLINE + ShowFields.COST,
  4. bool onlyOne = true,
  5. bool simplify = true,
  6. RouteResultBack? back,
})

线路规划 默认返回线路+费用(过路费+时间+距离..)

Implementation

static Future<void> routeSearch({
  required List<LatLng> wayPoints,
  int? strategy ,
  int? showFields = ShowFields.POLINE + ShowFields.COST,//ShowFields.
  bool onlyOne = true,//只返回第一条线路
  bool simplify = true,//简化数据
  RouteResultBack? back,
}) async {
  final String? jsonStr = await _channel.invokeMethod('routeSearch', {
    "wayPointsJson": json.encode(wayPoints),
    "strategy": strategy??DrivingStrategy.DEFAULT,
    "showFields": showFields,
    "onlyOne": onlyOne,
    "simplify":simplify,
  });
  if (jsonStr != null) {
    if(jsonStr.endsWith("FORCED_END")) return;
    Map? map = json.decode(jsonStr);
    if (map != null && back != null) {
      back(map['code'] as int, RouteResult.fromJson(map["data"]));
    }
  }
}