Open Maroben opened 8 years ago
Can't you check, if scale, crs and extent is available?
Then try this:
self.canvas = QgsMapCanvas() self.canvas.setExtent(layer.extent()) zoomRectangle = QgsRectangle(pos[0]-offset, pos[1]-offset,pos[0]+offset,pos[1]+offset) self.canvas.setExtent(zoomRectangle) self.canvas.refresh()
or
render = QgsMapRenderer()
rect = QgsRectangle(render.fullExtent())
render.setExtent(rect)
render.setDestinationCrs()
or qgis.utils.iface.mapCanvas().zoomScale(1000)
See http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/
When the plugin opens an MBTile and adds the 1st layer after a fresh start of QGIS (nothing is loaded in the mercator crs), the scale and coordinates are somehow invalid. Current workaround is, to load some kind of base map before, for example OSM.
Set the center from the mbtiles' metadata as the mapcanvas extent in Qgis.