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