showDirections method
Future<void>
showDirections({
- required MapType mapType,
- required Coords destination,
- String? destinationTitle,
- Coords? origin,
- String? originTitle,
- List<
Waypoint> ? waypoints, - DirectionsMode? directionsMode = DirectionsMode.driving,
- Map<
String, String> ? extraParams,
override
Opens the map application specified by mapType
and shows directions to destination
.
mapType
: The map application to launch.destination
: Coordinates of the destination.destinationTitle
: Optional label for the destination.origin
: Optional starting point. If omitted, the map app may use the current location.originTitle
: Optional label for the origin.waypoints
: Optional list of intermediate waypoints along the route.directionsMode
: Mode of transport (default is DirectionsMode.driving).extraParams
: Extra map-specific query parameters.
Implementation
@override
Future<void> showDirections({
required MapType mapType,
required Coords destination,
String? destinationTitle,
Coords? origin,
String? originTitle,
List<Waypoint>? waypoints,
DirectionsMode? directionsMode = DirectionsMode.driving,
Map<String, String>? extraParams,
}) async {
final url = getMapDirectionsUrl(
mapType: mapType,
destination: destination,
destinationTitle: destinationTitle,
origin: origin,
originTitle: originTitle,
waypoints: waypoints,
directionsMode: directionsMode,
extraParams: extraParams,
);
final Map<String, dynamic> args = {
'mapType': mapType.name,
'url': url,
'destinationTitle': destinationTitle,
'destinationLatitude': destination.latitude.toString(),
'destinationLongitude': destination.longitude.toString(),
'destinationtitle': destinationTitle,
'originLatitude': origin?.latitude.toString(),
'originLongitude': origin?.longitude.toString(),
'originTitle': originTitle,
'directionsMode': directionsMode?.name,
'waypoints': waypoints
?.map(
(waypoint) => {
'latitude': waypoint.latitude.toString(),
'longitude': waypoint.longitude.toString(),
'title': waypoint.title,
},
)
.toList(),
};
await methodChannel.invokeMethod('showDirections', args);
}