Graphics Reference
In-Depth Information
info.append("Timezone: " + timezone)
longitude = geometry.asPoint().x()
latitude = geometry.asPoint().y()
info.append("Lat/Long: %0.4f, %0.4f" %
(latitude,
longitude))
QMessageBox.information(self.window,
"Feature Info",
"\n".join(info))
This tool identifies the landmark feature the user clicked on, extracts the relevant attrib-
utes for that feature, and displays the results in a message box. To use our new map tool,
we'll have to add the following to the end of our MapExplorer window's
__init__() method:
self.exploreTool = ExploreTool(self)
self.exploreTool.setAction(self.actionExplore)
We'll then need to implement our setExploreMode() method to use this tool:
def setExploreMode(self):
self.actionPan.setChecked(False)
self.actionExplore.setChecked(True)
self.mapCanvas.setMapTool(self.exploreTool)
Notice that when the user switches to the explore mode, we have to uncheck the panning
mode action. This ensures that the two modes are mutually exclusive. The final step we
have to take is to modify our setPanMode() method so that it unchecks the explore
mode action when the user switches back to the panning mode. To do this, add the follow-
ing highlighted line to your setPanMode() method:
def setPanMode(self):
self.actionPan.setChecked(True)
self.actionExplore.setChecked(False)
self.mapCanvas.setMapTool(self.panTool)
Search WWH ::




Custom Search