1

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)

1 Answer 1

2

I figured it out. It's just the next thing:

map1.setLayers([points,layer,basemap])

and

map2.setLayers([points,layer,basemap])

Before I was thinkin that it would refresh/save it the same way as with GUI.

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.