def on_AddLayerButton_clicked(self): """ Add the layers to the map canvas """ countriesLineEdit = self.countriesLineEdit platesLineEdit = self.platesLineEdit eqLineEdit = self.eqLineEdit #Check the layers are valid Countries = AddLayers().CheckAddLayers(countriesLineEdit, "countries") plates = AddLayers().CheckAddLayers(platesLineEdit, "plate_boundaries") earthquakes = AddLayers().CheckAddLayers(eqLineEdit, "earthquakes") #ensure the countries layer renders in a suitable colour if Countries is not None: CountriesRenderer = Countries.rendererV2() CountriesSymbol = CountriesRenderer.symbol() CountriesSymbol.setColor(QColor('#31a354')) #ensure that the correct CRS is set for the earthquakes layer if earthquakes is not None: earthquakes.setCrs(QgsCoordinateReferenceSystem(4326, QgsCoordinateReferenceSystem.EpsgCrsId)) #add layers and trigger map tips 'on' layerList = [Countries, plates, earthquakes] QgsMapLayerRegistry.instance().addMapLayers(layerList) iface.actionMapTips().trigger()
def on_AddWoodLayer_clicked(self): """ Add the woodland layer to the map canvas """ woodLineEdit = self.woodLineEdit #Check the layer is valid woodland = AddLayers().CheckAddLayers(woodLineEdit, "woodland") #ensure the woodland layer renders in purple! if woodland is not None: woodRenderer = woodland.rendererV2() woodSymbol = woodRenderer.symbol() woodSymbol.setColor(QColor('#cc33ff')) #add layer QgsMapLayerRegistry.instance().addMapLayer(woodland)
def on_AddCountriesLayerButton_clicked(self): """ Add the layers to the map canvas """ CountrieslineEdit = self.CountrieslineEdit #Check the layer is valid Countries = AddLayers().CheckAddLayers(CountrieslineEdit, "countries") #ensure that the layer renders in a suitable colour if Countries is not None: CountriesRenderer = Countries.rendererV2() CountriesSymbol = CountriesRenderer.symbol() CountriesSymbol.setColor(QColor('#31a354')) #add the layer to the canvas and trigger map tips on QgsMapLayerRegistry.instance().addMapLayer(Countries) iface.actionMapTips().trigger()
def on_AddSettlementLayer_clicked(self): """ Add label layer with transparent points and labels enabled """ #check layer is valid labels = AddLayers().CheckAddLayers(self.settlementLineEdit, "settlement_names") #if valid, make layer points appear invisible and apply labels if labels is not None: labelsRenderer = labels.rendererV2() labelsSymbol = labelsRenderer.symbol() color = QColor(0, 0, 0, 0) labelsSymbol.setColor(QColor(0, 0, 0, 0)) labelsSymbol = QgsMarkerSymbolV2.createSimple({'color': '0,0,0,0', 'color_border': '0,0,0,0'}) labelsRenderer.setSymbol(labelsSymbol) #add layer to map canvas QgsMapLayerRegistry.instance().addMapLayer(labels) #set labels to settlement names Label().nameLabel("settlement_names", "NAME")