Book Image

Building Mapping Applications with QGIS

By : Erik Westra
Book Image

Building Mapping Applications with QGIS

By: Erik Westra

Overview of this book

Table of Contents (16 chapters)
Building Mapping Applications with QGIS
About the Author
About the Reviewers
Free Chapter
Getting Started with QGIS

Creating the map canvas

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

        self.mapCanvas = QgsMapCanvas()

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)

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...