3

Although I have checked the "Create Legend" option in the qgis2leaf plugin, it did not generate any legend in the output webmap.

What am I missing here ?

enter image description here

5

See their help page (on the help tab in the plugin UI):

When you're interested in building a legend as well, you need to fill the column legend_exp with a text and legend_ico with the path to an icon which should be shown in the legend for the particular layer. This works only for local layers and non-raster layers. See the example files for details.

  • It didn't work out. I've created a column (don't know should it be in a single file or all the layers, but tried both) with all the respective legend texts. But still the same – joseph_k Sep 9 '14 at 11:06
  • Hm. The legend part in the plugin source starts at line 945 github.com/Geolicious/qgis2leaf/blob/master/… , maybe you can figure out how to get the legend to work. – til_b Sep 9 '14 at 11:58
  • 1
    OK. I've figured it out. The legend will not be shown unless there is a proper & valid image path is specified (legend_ico). Now it's working perfectly – joseph_k Sep 10 '14 at 4:01
2

you must provide a proper name in the attribute legend_exp and a path to an image of your choice in legend_ico.

ATM we check whether both columns are there and build the table from what is inside the first column entry:

if legend_ico_prov == True and legend_exp_prov == True:
                            iter = i.getFeatures()
                            for feat in iter:
                                fid = feat.id()
                                provider = i.dataProvider()
                                legend_ico_index = provider.fieldNameIndex('legend_ico')
                                legend_exp_index = provider.fieldNameIndex('legend_exp')
                                attribute_map = feat.attributes()
                                legend_icon = attribute_map[legend_ico_index]
                                legend_expression = attribute_map[legend_exp_index]
                                print legend_expression
                                print legend_icon 
                                break
                            legendStart += """<tr><td><img src='""" + unicode(legend_icon) + """'></img></td><td>"""+unicode(legend_expression) + """</td></tr>"""

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.