Пример #1
0
    def addLayer(self, layerType):
        layer = OpenlayersLayer(self.iface, self._olLayerTypeRegistry)
        layer.setLayerName(layerType.displayName)
        layer.setLayerType(layerType)
        if layer.isValid():
            coordRefSys = layerType.coordRefSys(self.canvasCrs())
            self.setMapCrs(coordRefSys)
            QgsMapLayerRegistry.instance().addMapLayer(layer)

            # last added layer is new reference
            self.setReferenceLayer(layer)
Пример #2
0
 def addLayer(self, layerType):
     self.__setMapSrsGoogle()
     layer = OpenlayersLayer(self.iface, self.__coordRSGoogle, self.olLayerTypeRegistry)
     layer.setLayerName(layerType.name)
     layer.setLayerType(layerType)
     if layer.isValid():
         if QGis.QGIS_VERSION_INT >= 10900:
             QgsMapLayerRegistry.instance().addMapLayers([layer])
         else:
             QgsMapLayerRegistry.instance().addMapLayer(layer)
     # last added layer is new reference
     self.setReferenceLayer(layer)