3
canvas = iface.mapCanvas()
polyline = QgsRubberBand(canvas, False)  # False = not a polygon
points = [QgsPoint(1,1), QgsPoint(2,2), QgsPoint(3,3), QgsPoint(4,4)]
polyline.setToGeometry(QgsGeometry.fromPolyline(points), None)
polyline.setColor(QColor(255, 0, 0))
polyline.setWidth(3)

This is my sample code. I want to be able to append points to the line rather than updating my list and providing the same list again. Is there any way to do so?

1 Answer 1

2

You can add a new point to the existing rubber band using addPoint method.

For example: polyline.addPoint(QgsPointXY(10,4))

enter image description here

1
  • Thanks! How could I not see that. facepalm
    – peterbrown
    Sep 7, 2020 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.