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 our main QGIS application...
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime