Created
August 18, 2016 06:15
-
-
Save nyalldawson/a827d6909a0e1d48a7bbc518e5f8ffad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c=iface.activeComposers()[0] | |
c = c.composition() | |
maps=[i for i in c.items() if i.type()==QgsComposerItem.ComposerMap] | |
l = iface.activeLayer() | |
for m in maps: | |
f = QgsFeature() | |
f.setFields(l.fields()) | |
f.setAttributes([m.displayName()]) | |
extent = m.currentMapExtent() | |
g = QgsGeometry.fromRect(extent) | |
f.setGeometry(g) | |
l.addFeatures([f]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment