draw method

Future<RoadId> draw(
  1. List<GeoPoint> geometry, {
  2. RoadId? roadId,
  3. RoadOption option = const RoadOption.empty(),
})

Implementation

Future<RoadId> draw(
  List<GeoPoint> geometry, {
  RoadId? roadId,
  RoadOption option = const RoadOption.empty(),
}) async {
  if (geometry.length < 2) {
    throw _argumentException(_controller, 'drawRoad', 'invalid_geometry');
  }
  final id = roadId ?? _controller._nextRoadId();
  if (!_issuedIds.add(id)) {
    throw AndroidMapException(
      operation: 'drawRoad',
      code: 'duplicate_road_id',
      viewId: _controller.viewId,
      message: 'Road ID ${id.value} was already issued by this controller.',
    );
  }
  try {
    final transport = await _controller._readyTransport();
    await transport.drawRoad(
      id,
      List<GeoPoint>.unmodifiable(geometry),
      option,
    );
    return id;
  } catch (_) {
    _issuedIds.remove(id);
    rethrow;
  }
}