Graphics Reference
In-Depth Information
self.trackLayer = QgsVectorLayer(uri.uri(),
"Tracks",
"spatialite")
QgsMapLayerRegistry.instance().addMapLayer(
self.trackLayer)
layers.append(QgsMapCanvasLayer(self.trackLayer))
We can now set up a memory-based map layer to display the shortest path:
self.shortestPathLayer = QgsVectorLayer(
"LineString?crs=EPSG:4326",
"shortestPathLayer", "memory")
QgsMapLayerRegistry.instance().addMapLayer(
self.shortestPathLayer)
layers.append(QgsMapCanvasLayer(self.shortestPathLayer))
We saw how to create memory-based map layers in Chapter 6 , Mastering the QGIS
Python API , so there shouldn't be any surprises here; we're simply defining the shortest
path layer to hold a LineString geometry.
Next, we want to set up another memory-based map layer to show the user's selected start-
ing point:
self.startPointLayer = QgsVectorLayer(
"Point?crs=EPSG:4326",
"startPointLayer",
"memory")
QgsMapLayerRegistry.instance().addMapLayer(
self.startPointLayer)
layers.append(QgsMapCanvasLayer(self.startPointLayer))
Also, we want to set another map layer for the ending point:
self.endPointLayer = QgsVectorLayer(
"Point?crs=EPSG:4326",
"endPointLayer", "memory")
QgsMapLayerRegistry.instance().addMapLayer(
Search WWH ::




Custom Search