startNavigation method

Future startNavigation({
  1. required WayPoint origin,
  2. required WayPoint destination,
  3. required bool simulateRoute,
  4. required bool setDestinationWithLongTap,
  5. String? msg,
  6. String? profile,
  7. String? style,
  8. String? voiceUnits,
  9. String? language,
  10. bool? alternativeRoute,
})

Implementation

Future<dynamic> startNavigation({
  required WayPoint origin,
  required WayPoint destination,
  required bool simulateRoute,
  required bool setDestinationWithLongTap,
  String? msg,
  String? profile,
  String? style,
  String? voiceUnits,
  String? language,
  bool? alternativeRoute,
}) {
  // The data we receive is stored in a variable type map
  Map data = {
    'destination': {
      'Latitude': destination.latitude,
      'Longitude': destination.longitude
    },
    'origin': {'Latitude': origin.latitude, 'Longitude': origin.longitude},
    'simulateRoute': simulateRoute,
    'setDestinationWithLongTap': setDestinationWithLongTap,
    'msg': (msg != null) ? msg : '',
    'profile': (profile != null) ? profile : '',
    'style': (style != null) ? style : '',
    'voiceUnits': (voiceUnits != null) ? voiceUnits : '',
    'language': (language != null) ? language : '',
    'alternativeRoute': (alternativeRoute != null) ? alternativeRoute : false,
  };
  // then we send the data to the method that starts the map
  return NavigationWithMapboxPlatform.instance.startNavigation(data);
}