Geographic Information Systems Asked on August 10, 2021
When I try to read the expression variable @map_id using a Python expression function (see code below) inside a label text, it always returns "canvas" as result. When I use @map_id directly, it returns the correct name of a layout map item. What can I do to automatically retrieve the correct map id with Python?
@qgsfunction(args='auto', group='Custom')
def getMapId(feature, parent):
return QgsExpressionContextUtils.mapSettingsScope(QgsMapSettings()).variable("map_id")
BTW: using QgsExpression("@map_id")
doesn’t work either.
My ultimate goal is to create a function that will return the extents of a map item so that I can speed up my virtual layers by restricting the query to that area.
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP