I'm developing a QGIS plugin and I need some help with styling layers in different canvas objects.
In my dialog window I've got two QgsMapCanvas objects canvas1
and canvas2
. Layers from registry are loaded to both objects (the same list of layers).
for layer in QgsMapLayerRegistry.instance().mapLayers().values():
# appending layer to list
canvas1.setLayerSet(list)
canvas2.setLayerSet(list)
Now in both canvas objects I've got the same map composition.
Next I want to change layer style only in canvas1
. I've tried:
layers = canvas1.layers()
# get polygon layer
layer = layers[0]
# set properties
properties = {"color": "255,0,0", "outline_color": "255,0,255"}
s = QgsFillSymbolV2.createSimple(properties)
layer.setRendererV2( QgsSingleSymbolRendererV2(s))
But this layer style is changed in all of the canvas objects (canvas1
, canvas2
and main canvas in Qgis).
How could I change styles for only one canvas in the most efficient way?
layer = layer[0]
belayer = layers[0]
?