I am able to access the map canvas center in the python console in QGIS using


What I would like to do is get this into a map composer label.

Is this possible?


Got it working now using this user-defined function.

from qgis.core import *
from qgis.gui import *
from qgis.utils import iface

@qgsfunction(args=0, group='Custom', usesgeometry=True)
def mapCenter(value1,feature, parent):
        point = iface.mapCanvas().extent().center().toString()
        return point
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.