2

I'm going to build a QGIS standalone application. According to the requirements full extent equals to the extent of a predefined rectangle (say bounding box of a parcel). The application should start in full extent view. When zoomed in the user is restricted to only pan inside the area given by full extent (using pan tool or sliding scrollbars), similar to the issue in this question.

Which is the appropriate QGIS API function or how can I mimic this behaviour using Python?

2

You can listen to the extent changed event and reset it back if it goes outside of the bounds:

def extentsChanged():
   extent = iface.mapCanvas().extent()
   outofbounds = # Do your check
   if outofbounds:
     iface.mapCanvas().setExtent(newextent)

iface.mapCanvas().extentsChanged.connect(extentsChanged)
0

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.