getCoorsStartToEnd method

Future<RouteDestination> getCoorsStartToEnd(
  1. LatLng start,
  2. LatLng end
)

Implementation

Future<RouteDestination> getCoorsStartToEnd(LatLng start, LatLng end) async {
  final TrafficResponse trafficResponse =
      await trafficService.getCoorsStartToEnd(start, end);

  final Feature initialPlace =
      await trafficService.getInformationCoors(start);
  final Feature finishPlace = await trafficService.getInformationCoors(end);

  final Route firstRoute = trafficResponse.routes[0];

  final String geometry = firstRoute.geometry;
  final double distance = firstRoute.distance;
  final double duration = firstRoute.duration;

  final points = decodePolyline(geometry, accuracyExponent: 6);

  final List<LatLng> latLngList = points
      .map((coor) => LatLng(coor[0].toDouble(), coor[1].toDouble()))
      .toList();
  return RouteDestination(
      points: latLngList,
      duration: duration,
      distance: distance,
      initialPlace: initialPlace,
      finishPlace: finishPlace);
}