Friday, 19 May 2017

qgis - Is rule-based labelling available for qgis2web plugin?


Does the qgis2web plugin support multi-attribute, rule-based labeling?


I'm trying to use the qgis2web plugin to export leaflet maps. The labeling on the map I want to export is rule-based. (eg if x > 0 label with a || x). An export with this style produces a map with no labels.


web map with no labels


Here's what it looks like fully functional in QGIS: multi-attribute, multi-line labels work in QGIS


If I get rid of the rule-based label, but still use the multi-attibute, multi-line label (eg “X” || ‘\n’ “Y” ), I get a Python export error and no web map is produced.



So in trying to troubleshoot, I changed all the symbology and labels to the simplest terms, and the map successfully exports with labels (but is ugly and doesn't display the data I want). That leads me to believe it is the multi-attribute, rule-based labeling that is the problem. ugly map that works


So in summary, does the qgis2web plugin support these types of labeling schema and I'm just doing it wrong, or is that a feature that's not available?



Answer



As far as I can see, rule-bases styles are supported, but not rule-based labelling.


But you can modify the js code manually afterwards to use different labelling for each defined rendering style rules.


Multi-line labels are possible, but the syntax in QGIS is something like


"city_label" || '\n' || "shape_area"


and you might have to escape empty (NULL) values.


If your aim is to exclude polygons with NULL or zero values from rendering and labelling, think of setting a filter in the layer's properties before exporting to web.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...