I'm trying to create a plugin for QGIS using python, But need some help. I want to 1.Zoom to a layer and 2. make the layer visible(switch off or on).
But I have managed to zoom to an active layer by setting the active layer in the map canvas by using.
import qgiscanvas = qgis.utils.iface.mapCanvas()acl = canvas.layer(1)qgis.utils.iface.setActiveLayer(acl)> Trueqgis.utils.iface.zoomToActiveLayer()But this only work as long as the layer is viable(obviously since I use canvas). So I need another way to "point" to a layer and then zoom to and switch off.
Thanks.
أكثر...
But I have managed to zoom to an active layer by setting the active layer in the map canvas by using.
import qgiscanvas = qgis.utils.iface.mapCanvas()acl = canvas.layer(1)qgis.utils.iface.setActiveLayer(acl)> Trueqgis.utils.iface.zoomToActiveLayer()But this only work as long as the layer is viable(obviously since I use canvas). So I need another way to "point" to a layer and then zoom to and switch off.
Thanks.
أكثر...