title: Select and zoom features of a layer using PyQgis
body: <p>I want to select features and to zoom on them and do all these steps using PyQgis.</p>
  
  <p>And I'm able to do both of them separatly but it doesn't seems to work when I try to mix the two of them.</p>
  
  <p>Both of the codes I use for them are from the internet. Here's what I use to select features of a layer :</p>
  
  <pre><code>from qgis.core import *
  import qgis.utils
  lyrMap = QgsVectorLayer('C:/someplace', 'MapName', 'ogr')
  QgsMapLayerRegistry.instance().addMapLayer(lyrMap)
  
  expr = QgsExpression("'Attribute' IS NOT NULL")
  it = lyrMap.getFeatures(QgsFeatureRequest(expr))
  ids = [i.id() for i in it] #select only the features for which the expression is true
  lyrMap.setSelectedFeatures(ids)
  </code></pre>
  
  <p>And it seems to do the trick as features appear selected on QGis.</p>
  
  <p>In order to zoom the code is much more simple, it's just :</p>
  
  <pre><code>canvas = qgis.utils.iface.mapCanvas()
  canvas.zoomToSelected(lyrMap)
  </code></pre>
  
  <p>But it seems that canvas doesn't consider that there's a selection on lyrMap and simply do nothing. I've tried to do the selection manually in QGis, and then zoom using zoomToSelected, and it worked.</p>
  
  <p>But my objective is to do it without needing to do the selection manually...</p>
  
  <p>Note : I don't think that's the issue, but the attribute I'm doing the selection on is from a join between lyrMap and another layer (I didn't put the code here because I don't think it's linked).</p>
  
  <p>Thanks in advances for answers, clues or anything really :) !</p>