I have the following case:
- Project consists of three layers:
- OpenLayers plugin with Google streets
- QGSVector layer with Point features and Label enabled
- QGSVector layer with Polyline features and Label enabled
I need to (1) zoom extent canvas for both #2 and #3 and (2) make sure Labels are visible for all the features placed on these two layers.
I'm using the following code:
idList = []
idList.append(vlPoint.id())
idList.append(vlLine.id())
render = QgsMapRenderer()
render.setLayerSet(idList)
canvas = qgis.utils.iface.mapCanvas()
canvas.setExtent(render.fullExtent())
canvas.refresh()
The result of this code execution is below:
As you see the very upper point feature is displayed partially and its label is missed at all. If I zoom out canvas manually just a little- everything is displayed OK.
Need to know how to correctly zoom to extent in my case - to make sure all the features and labels are displayed.
If I have only one vector layer - the following code solves such issue:
vlPoint.selectAll()
canvas.zoomToSelected()
vlPoint.removeSelection()
But for two layers this approach doesn't work.