renderWay method

  1. @override
void renderWay(
  1. RenderInfo<Renderinstruction> renderInfo,
  2. RenderContext renderContext,
  3. WayProperties wayProperties
)

Renders an icon for a way.

The icon is drawn at the center of the way's bounding box.

Implementation

@override
void renderWay(RenderInfo renderInfo, RenderContext renderContext, WayProperties wayProperties) {
  if (renderContext is! UiRenderContext) throw Exception("renderContext is not UiRenderContext ${renderContext.runtimeType}");
  if (textPainter == null) return;
  Mappoint point = wayProperties.getCenterAbsolute(renderContext.projection);
  MappointRelative relative = point.offset(renderContext.reference);
  MapRectangle boundary = renderinstruction.getBoundary(renderInfo);
  UiMatrix? matrix;
  if (renderinstruction.theta != 0 || renderContext.rotationRadian != 0) {
    matrix = UiMatrix();
    matrix.rotate(renderinstruction.theta - renderContext.rotationRadian, pivotX: boundary.left, pivotY: boundary.top);
  }

  renderContext.canvas.drawIcon(textPainter: textPainter!, left: relative.dx + boundary.left, top: relative.dy + boundary.top, matrix: matrix);
}