diff --git a/felt/core/fsl_converter.py b/felt/core/fsl_converter.py index 2f4f39b..ee9d7c8 100644 --- a/felt/core/fsl_converter.py +++ b/felt/core/fsl_converter.py @@ -1199,6 +1199,10 @@ def label_settings_to_fsl(settings: QgsPalLayerSettings, settings.minimumScale) converted_format['maxZoom'] = MapUtils.map_scale_to_leaflet_tile_zoom( settings.maximumScale) + else: + # these are mandatory! + converted_format['minZoom'] = 1 + converted_format['maxZoom'] = 24 res = { 'config': { diff --git a/felt/core/layer_exporter.py b/felt/core/layer_exporter.py index 0a93f88..350e6ff 100644 --- a/felt/core/layer_exporter.py +++ b/felt/core/layer_exporter.py @@ -203,6 +203,22 @@ def import_from_url(layer: QgsMapLayer, target_map: Map, ) return json.loads(reply.content().data().decode()) + @staticmethod + def merge_dicts(tgt: Dict, enhancer: Dict) -> Dict: + """ + Recursively merges two dictionaries + """ + for key, val in enhancer.items(): + if key not in tgt: + tgt[key] = val + continue + + if isinstance(val, dict): + LayerExporter.merge_dicts(tgt[key], val) + else: + tgt[key] = val + return tgt + @staticmethod def representative_layer_style(layer: QgsVectorLayer) -> LayerStyle: """ @@ -217,7 +233,15 @@ def representative_layer_style(layer: QgsVectorLayer) -> LayerStyle: ) if fsl: fsl['version'] = '2.1' - # TODO -- labeling + + if layer.labelsEnabled(): + label_def = FslConverter.label_settings_to_fsl( + layer.labeling().settings(), + context + ) + if label_def: + LayerExporter.merge_dicts(fsl, label_def) + return LayerStyle( fsl=fsl )