getRoute method

Future<MPRoute> getRoute({
  1. required MPPoint origin,
  2. required MPPoint destination,
  3. List<MPPoint>? stops,
  4. bool? optimize = false,
})

Queries the routing network to generate a route from the origin to the destination.

Can be supplied with a list of stops to visit on the way, and whether to optimize the order of the stops.

Can throw an MPError if unable to generate the route.

Implementation

Future<MPRoute> getRoute(
    {required MPPoint origin,
    required MPPoint destination,
    List<MPPoint>? stops,
    bool? optimize = false}) {
  return DirectionsServicePlatform.instance.getRoute(
      MPPoint.withCoordinates(
          longitude: origin.longitude,
          latitude: origin.latitude,
          floorIndex: origin.floorIndex != MPPoint.noFloorIndex
              ? origin.floorIndex
              : 0),
      MPPoint.withCoordinates(
          longitude: destination.longitude,
          latitude: destination.latitude,
          floorIndex: destination.floorIndex != MPPoint.noFloorIndex
              ? destination.floorIndex
              : 0),
      stops
          ?.map((it) => MPPoint.withCoordinates(
              longitude: it.longitude,
              latitude: it.latitude,
              floorIndex:
                  it.floorIndex != MPPoint.noFloorIndex ? it.floorIndex : 0))
          .toList(),
      optimize);
}