Hi Patrick,
what about
iface.mapCanvas().setExtent(layer.extent())
iface.mapCanvas().refresh()
or
iface.setActiveLayer(layer)
iface.zoomToActiveLayer()
hth
Ludwig
Am 18.11.23 um 09:32 schrieb Patrick Dunford via QGIS-User:
Good day to all
I want to call zoomToLayers in a pyqgis script to zoom the map canvas
to a layer which I have just applied a filter to. I am not sure how to
do it as all the documented uses of this method seem to apply to
different things than to a layer.
If the layer is not the currently active layer is there a method of
this that can be called on a particular layer or selecting a
particular layer as active then using the call that uses the active
layer.
e.g.
project =QgsProject.instance()
layer = project.mapLayersByName("Live Aerial Footprints")[0]
layer.setSubsetString(aerialFilter)
# insert code here to zoom to this layer
Thanks
_______________________________________________
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
_______________________________________________
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user