_redraw()

in maplibre-js-react-iot-asset-tracking/src/PolylineOverlay.js [11:31]


  _redraw({ width, height, ctx, isDragging, project, unproject }) {
    const {
      points,
      color = "green",
      lineWidth = 3,
      renderWhileDragging = true,
    } = this.props;
    ctx.clearRect(0, 0, width, height);
    ctx.globalCompositeOperation = "lighter";

    if ((renderWhileDragging || !isDragging) && points) {
      ctx.lineWidth = lineWidth;
      ctx.strokeStyle = color;
      ctx.beginPath();
      points.forEach((point) => {
        const pixel = project([point.Position[0], point.Position[1]]);
        ctx.lineTo(pixel[0], pixel[1]);
      });
      ctx.stroke();
    }
  }