Adding standard map tools to the canvas
In this recipe, you'll learn how to add standard map navigation tools to a standalone map canvas. Creating the simplest possible interactive application provides a framework to begin building specialized geospatial applications using QGIS as a library.
Getting ready
Download the following zipped shapefile and extract it to your qgis_data
directory into a folder named ms
from https://github.com/GeospatialPython/Learn/raw/master/Mississippi.zip.
How to do it...
We will walk you through the steps required to create a map canvas, add a layer to it, and then add some tools to zoom and pan the map, which are given as follows:
First, because we are working outside the QGIS Python interpreter, we need to import some QGIS and Qt libraries:
from qgis.gui import * from qgis.core import * from PyQt4.QtGui import * from PyQt4.QtCore import SIGNAL, Qt import sys, os
Then, we must set the location of...