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();
debugPrint((roadOption?.roadBorderColor ?? Colors.green).toHexColor());
var roadInfo = RoadInfo();
interop.drawRoad(
mapIdMixin,
roadInfo.key,
routeJs,
((roadOption ?? defaultRoadOption)?.roadColor ?? Colors.green)
.toHexColor(),
((roadOption ?? defaultRoadOption)?.roadWidth ?? 5.0).toDouble(),
(roadOption ?? defaultRoadOption)?.zoomInto ?? true,
((roadOption ?? defaultRoadOption)?.roadBorderColor ?? Colors.green)
.toHexColor(),
(roadOption ?? defaultRoadOption)?.roadBorderWidth ?? 0,
interestPoints?.toListGeoPointJs() ?? [],
null,
);
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;
}