I am working on a plugin that would highlight selected features by changing its color. Can anyone help me regarding this? The plugin searches for required features and once found, I want that those features are highlighted with color different from the layer color. How to do this?
Here is the snippet:
def processResults(self, results): if self.layer is None: return if self.selectBox.isChecked(): self.layer.setSelectedFeatures(results) if len(results) == 0: return if self.panBox.isEnabled() and self.panBox.isChecked(): canvas = self.iface.mapCanvas() rect = canvas.mapRenderer().layerExtentToOutputExtent(self.layer, self.layer.boundingBoxOfSelected()) if rect is not None: if self.scaleBox.isEnabled() and self.scaleBox.isChecked(): rect.scale(1.5) canvas.setExtent(rect) else: canvas.setExtent(QgsRectangle(rect.center(), rect.center())) canvas.refresh()
This code just scales the canvas 1.5 times, what I want is not zooming in it, but just highlight it on the same scale by either changing color or any other means. How to do it?