I am writing a plugin in QGIS with python where the user can select one or more objects to view information on one of these objects. I am making it so that the user can click them back and forth between the selected objects. The problem is that you can't see in the map which object you are currently looking at.

Is there a way to mark one of the selected object more or in another way than they already are?

1 Answer 1


You can use a QgsVertexMarker to draw a canvas item at the desired objects location.

marker = QgsVertexMarker(iface.mapCanvas())
marker.setCenter(QgsPointXY(-151.0, 62.0))
marker.setColor(QColor(0, 255, 0))

or you can use a QgsRubberBand with a given feature to highlight it:

# create the rubberband
rb = QgsRubberBand(iface.mapCanvas())
# set the fill color to red with 50% transparency
rb.setColor(QColor(255, 0, 0, 128))
# set the rubberband shape (geometry) to that of the feature
rb.setToGeometry(feature.geometry(), wb)

You'll have to track the objects in order to remove them using:


A good source for this info the PyQGIS Programmer's Guide from Locate Press.

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.