On QGIS, I am using a simple script to zoom the selected features. I write them in the Text Editor, but it didn't work until I used the console... and it does work. What kind of problem is this? Is there a token or anything I should introduce in the text editor?
municipios = QgsVectorLayer("\\","name","ogr") QgsMapLayerRegistry.instance().addMapLayer(municipios) l = iface.mapCanvas().layers() expr = QgsExpression( "" ) it = l.getFeatures( QgsFeatureRequest( expr )) itera = [i.id() for i in it] l.setSelectedFeatures( itera ) iface.mapCanvas().zoomToSelected()
This is the error message (but not having it in my console, only with Text Editor of QGIS)
Traceback (most recent call last): File "", line 1, in File "c:/users/miguel~1/appdata/local/temp/tmpmlvs3w.py", line 9, in it = l.getFeatures( QgsFeatureRequest( expr )) AttributeError: 'list' object has no attribute 'getFeatures'