Saturday, 18 February 2017

qgis - How to zoom to the extent of a Qgsvectolayer using PyQGIS?



Anyone know how to zoom to the extent of a Vectorlayer in QGIS using python plugin?



Answer



You'd get the app's Map Canvas and set its extent.


canvas = qgis.utils.iface.mapCanvas()
canvas.setExtent(layer.extent())

You might want to read this tutorial.


No comments:

Post a Comment