def on_AddAttractionLayer_clicked(self):
     """
     add the tourist attraction layer to the mao
     """
     #check layer is valid
     attractions = AddLayers().CheckAddLayers(self.attractionLineEdit,  "tourist_attraction")
     # add layer to map canvas
     QgsMapLayerRegistry.instance().addMapLayer(attractions)
     
     #if valid, populate the combobox on the next page with types of attraction
     if attractions is not None:
         attractionTypes = colourManager().getAttributes("LEGEND",  attractions)
         self.fieldComboBox.addItems(attractionTypes)
         
         colorList = [QColor('#8dd3c7'), QColor('#ffffb3'), QColor('#bebada'), QColor('#fb8072'), QColor('#80b1d3'), QColor('#fdb462'), QColor('#b3de69'), QColor('#fccde5'), QColor('#d9d9d9'), QColor('#bc80bd'), QColor('#ccebc5'), QColor('#ffed6f'), QColor('#6699ff'),QColor('#ff1975'),QColor('#3399ff')]
         catList = []
         #apply a default colour scheme to the attractions based on attraction type
         for attraction in attractionTypes:
             colorIndex = attractionTypes.index(attraction)
             symbol = QgsSymbolV2.defaultSymbol(attractions.geometryType())
             symbol.setColor(colorList[colorIndex])
             cat = QgsRendererCategoryV2(attraction, symbol ,  str(attraction))
             catList.append(cat)
         
         renderer = QgsCategorizedSymbolRendererV2("LEGEND", catList)
         
         attractions.setRendererV2(renderer)
         
         #refresh map canvas and legend
         iface.mapCanvas().refresh()
         iface.legendInterface().refreshLayerSymbology(attractions)
         
         #make a legend table in the plugin
         colourManager().makeClassTable(attractions,  "LEGEND",  self.AttractionTableView)
 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_AddObesityLayerButton_clicked(self):
     """
     Add the layers to the map canvas
     """
     obesitylineEdit = self.obesitylineEdit
     
     obesityLayer = AddLayers().CheckAddLayers(obesitylineEdit,  "obesity")
     
     QgsMapLayerRegistry.instance().addMapLayer(obesityLayer)
     
     fields = obesityLayer.pendingFields()
     fieldList = []
     for field in fields:
         fieldList.append(field.name())
     self.obesityColumncomboBox.addItems(fieldList[10:])
 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")