route static method
void
route({
- required List<
LatLng> wayPoints, - int? strategy,
- PlanningCallBack? planningBack,
- CalculateCallBack? calculateBack,
Implementation
static void route({required List<LatLng> wayPoints, int? strategy, PlanningCallBack? planningBack, CalculateCallBack? calculateBack}) {
routeSearchPage(
wayPoints: wayPoints,
strategy: strategy ?? DrivingStrategy.DEFAULT,
showFields: ShowFields.POLINE+ShowFields.COST,
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 (planningBack != null) planningBack((code), [], LatLngBounds(southwest: southwest, northeast: northeast));
if (calculateBack != null) calculateBack(0,0);
return;
}
if(data.paths==null|| data.paths!.isEmpty) return;
if (planningBack != null) {
List<LatLng> points = PointUtil.listCover(data.paths![0].polyline);
planningBack(1000, points, PointUtil.lineBounds(points));
}
if(calculateBack != null){
calculateBack(data.paths![0].distance?.toInt()??0,data.paths![0].duration?.toInt()??0);
}
},
);
}