launchMapsDirections static method

void launchMapsDirections({
  1. String? destinationTitle,
  2. String? originTitle,
  3. List<Coords>? waypoints,
  4. DirectionsMode directionsMode = DirectionsMode.driving,
  5. Map<String, String>? extraParams,
  6. required double latitude,
  7. required double longitude,
  8. double? latitudeOrigin,
  9. double? longitudeOrigin,
})

Implementation

static void launchMapsDirections({
  String? destinationTitle,
  String? originTitle,
  List<Coords>? waypoints,
  DirectionsMode directionsMode = DirectionsMode.driving,
  Map<String, String>? extraParams,
  required double latitude,
  required double longitude,
  double? latitudeOrigin,
  double? longitudeOrigin,
}) async {
  try {
    final availableMaps = await MapLauncher.installedMaps;

    await availableMaps.first.showDirections(
      destinationTitle: destinationTitle,
      origin: longitudeOrigin != null && latitudeOrigin != null
          ? Coords(
              latitudeOrigin,
              longitudeOrigin,
            )
          : null,
      originTitle: originTitle,
      destination: Coords(
        latitude,
        longitude,
      ),
    );
  } catch (e) {
    LoggerService.logInfo('Utils launchMapsDirections: could not launch string: $destinationTitle');
  }
}