Our Ui_ExplorerWindow
class defines an instance variable named centralWidget
, which acts as a placeholder for our window's contents. Since we want to place a QGIS map canvas into our window, let's implement the code to create our map canvas and place it into this central widget. Add the following to the end of your MapExplorer
window's __init__()
method (in lex.py
):
self.mapCanvas = QgsMapCanvas() self.mapCanvas.useImageToRender(False) self.mapCanvas.setCanvasColor(Qt.white) self.mapCanvas.show() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.mapCanvas) self.centralWidget.setLayout(layout)
Next, we want to fill our map canvas with the basemap and landmark map layers. To do this, we'll define a new method called loadMap()
, and call this at the appropriate time. Add the following method to your MapExplorer
class:
def loadMap(self): cur_dir = os.path.dirname...