drawRoad method
Future<RoadInfo>
drawRoad(
- GeoPoint start,
- GeoPoint end, {
- RoadType roadType = RoadType.car,
- List<
GeoPoint> ? interestPoints, - RoadOption? roadOption,
inherited
Implementation
Future<RoadInfo> drawRoad(
GeoPoint start,
GeoPoint end, {
RoadType roadType = RoadType.car,
List<GeoPoint>? interestPoints,
RoadOption? roadOption,
}) async {
final geoPoints = [start, end];
if (interestPoints != null && interestPoints.isNotEmpty) {
geoPoints.insertAll(1, interestPoints);
}
final waypoints = geoPoints.toLngLatList();
final road = await manager.getRoad(
waypoints: waypoints,
roadType: routing.RoadType.values[roadType.index],
alternative: false,
geometries: routing.Geometries.geojson,
);
final routeJs = road.polyline!.mapToListGeoJS();
var roadInfo = RoadInfo();
final roadConfig =
roadOption ?? defaultRoadOption ?? const RoadOption.empty();
debugPrint(roadOption?.toString());
interop.drawRoad(
mapIdMixin.toJS,
roadInfo.key.toJS,
routeJs.toJS,
(interestPoints?.toListGeoPointJs() ?? []).toJS,
roadConfig.toRoadOptionJS,
);
final instructions = await manager.buildInstructions(road);
roadInfo = roadInfo.copyWith(
duration: road.duration,
distance: road.distance,
instructions: instructions
.map((e) => Instruction(
instruction: e.instruction,
geoPoint: e.location.toGeoPoint(),
))
.toList(),
route: road.polyline!.mapToListGeoPoints(),
);
roadsWebCache[roadInfo.key] = roadInfo;
return roadInfo;
}