From ed910263197d4af1ea58d9f3393e47a5fd9e8080 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Wed, 13 Sep 2023 12:55:37 +0200 Subject: [PATCH] Add `tolltip` and `popup` options to map layer configuration. - `tooltip` takes the name of a GeoJSON property that will be shown in a tooltip when hovering the mouse over a feature. - `popup` can take either the name of a property as above, or the boolean value `true`. In the latter case, a table of all the feature's properties will be shown when clicking on the feature. In the former case, only the value of the designated property will be shown. --- bin/import_map_layers.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/bin/import_map_layers.py b/bin/import_map_layers.py index 00a80f8..b31d864 100755 --- a/bin/import_map_layers.py +++ b/bin/import_map_layers.py @@ -56,16 +56,31 @@ if __name__ == '__main__': file_info = { "type": "map_layer", "format": layer["format"], - "name": layer_name + "name": layer_name, + "tooltip": layer.get("tooltip"), + "popup": layer.get("popup") } db.save_file_data(logical_filepath, json.dumps(file_info)) else: file_info = db.get_file_data(logical_filepath) - if file_info and file_info["name"] != layer_name: - print("Renaming to", layer_name) - file_info["name"] = layer_name + dirty = False + if file_info: + if file_info["name"] != layer_name: + print("Renaming to", layer_name) + file_info["name"] = layer_name + dirty = True + if file_info.get("tooltip") != layer.get("tooltip"): + print("Changing tooltip to", layer.get("tooltip") or "null") + file_info["tooltip"] = layer.get("tooltip") + dirty = True + if file_info.get("popup") != layer.get("popup"): + print("Changing popup to", layer.get("popup") or "null") + file_info["popup"] = layer.get("popup") + dirty = True + + if dirty: db.save_file_data(logical_filepath, json.dumps(file_info)) else: print("Already in DB")