6

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?

0

1 Answer 1

3

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.

1
  • 1
    This is correct - rule-based styles are supported, but rule-based labelling is not. Very happy to accept pull requests at github.com/tomchadwin/qgis2web if someone were prepared to develop the plugin to do this - it's certainly doable. But no, it's currently not supported. Commented Sep 10, 2018 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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