drawRoad method
Future<RoadInfo>
drawRoad(
- int idOSM,
- GeoPoint start,
- GeoPoint end, {
- RoadType roadType = RoadType.car,
- List<
GeoPoint> ? interestPoints, - RoadOption roadOption = const RoadOption.empty(),
override
Implementation
@override
Future<RoadInfo> drawRoad(
int idOSM,
GeoPoint start,
GeoPoint end, {
RoadType roadType = RoadType.car,
List<GeoPoint>? interestPoints,
RoadOption roadOption = const RoadOption.empty(),
}) async {
final roadInfo = RoadInfo();
/// add point of the road
final Map args = {
'key': roadInfo.key,
"wayPoints": [
start.toMap(),
end.toMap(),
]
};
/// add road type that will change api call to get route
args.addAll({
"roadType": roadType.toString().split(".").last,
});
/// add middle point that will pass through it
if (interestPoints != null && interestPoints.isNotEmpty) {
args.addAll(
{
"middlePoints": interestPoints.map((e) => e.toMap()).toList(),
},
);
}
args.addAll(roadOption.toMap());
try {
Map? map = await _channels[idOSM]?.invokeMapMethod(
"road",
args,
);
return RoadInfo.fromMap(map!);
} on PlatformException catch (e) {
throw RoadException(msg: e.message);
}
}