Print Layout from a template with two maps of the same layer, but different styling.
My code perfectly works for the first map:
#1
#getting map ID from the layout
map1 = layout.itemById('mapId_1')
#changing layer styling value
layer.renderer().setClassAttribute('attr_1')
#Locking map style
map1.setKeepLayerSet(True)
map1.setKeepLayerStyles(True)
But the same code for the second map doesn't work.
It's making two maps with second layer styling value attr_2
.
#2
#getting map ID from the layout
map2 = layout.itemById('mapId_2')
#changing layer styling
layer.renderer().setClassAttribute('attr_2')
#Locking map style
map2.setKeepLayerSet(True)
map2.setKeepLayerStyles(True)