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
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Getting Started with QGIS
Index

Implementing the explore mode


So far, the user can choose which map layers are displayed, and can zoom and pan the map view. The only thing missing is the entire point of the application: exploring landmarks. To do this, we'll have to implement our application's explore mode.

In the previous chapter, we saw how we can use a QgsMapToolIdentify subclass to respond when the user clicks on a vector feature. We're going to use the same logic here to implement a new map tool, which we'll call ExploreTool. Add the following class definition to your lex.py module after the PanTool class definition:

class ExploreTool(QgsMapToolIdentify):
    def __init__(self, window):
        QgsMapToolIdentify.__init__(self, window.mapCanvas)
        self.window = window

    def canvasReleaseEvent(self, event):
        found_features = self.identify(event.x(), event.y(),
                                       self.TopDownStopAtFirst,
                                       self.VectorLayer)
        if len(found_features...