From aeb356bf5480814bdd38f24331f69212d74d8dd2 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 24 Jul 2025 22:14:31 +0300 Subject: [PATCH] feat(views/geo): allow displaying scale --- apps/client/src/translations/en/translation.json | 3 ++- .../src/widgets/ribbon_widgets/book_properties_config.ts | 5 +++++ apps/client/src/widgets/view_widgets/geo_view/index.ts | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 073ca2803..a67bcd953 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -1970,7 +1970,8 @@ "max-nesting-depth": "Max nesting depth:", "raster": "Raster", "vector_light": "Vector (Light)", - "vector_dark": "Vector (Dark)" + "vector_dark": "Vector (Dark)", + "show-scale": "Show scale" }, "table_context_menu": { "delete_row": "Delete row" diff --git a/apps/client/src/widgets/ribbon_widgets/book_properties_config.ts b/apps/client/src/widgets/ribbon_widgets/book_properties_config.ts index de5bc6fda..3b76246d5 100644 --- a/apps/client/src/widgets/ribbon_widgets/book_properties_config.ts +++ b/apps/client/src/widgets/ribbon_widgets/book_properties_config.ts @@ -138,6 +138,11 @@ export const bookPropertiesConfig: Record = { .map(buildMapLayer) } ] + }, + { + label: t("book_properties_config.show-scale"), + type: "checkbox", + bindToLabel: "map:scale" } ] }, diff --git a/apps/client/src/widgets/view_widgets/geo_view/index.ts b/apps/client/src/widgets/view_widgets/geo_view/index.ts index 166c3ec17..170b67b20 100644 --- a/apps/client/src/widgets/view_widgets/geo_view/index.ts +++ b/apps/client/src/widgets/view_widgets/geo_view/index.ts @@ -164,6 +164,10 @@ export default class GeoView extends ViewMode { }); } + if (this.parentNote.hasLabel("map:scale")) { + L.control.scale().addTo(map); + } + this.$container.toggleClass("dark", !!layerData.isDarkTheme); layer.addTo(map); @@ -291,7 +295,7 @@ export default class GeoView extends ViewMode { } // Full reload if map layer is changed. - if (loadResults.getAttributeRows().some(attr => attr.name === "mapStyle" && attributes.isAffecting(attr, this.parentNote))) { + if (loadResults.getAttributeRows().some(attr => ((attr.name === "mapStyle") || (attr.name === "map:scale") && attributes.isAffecting(attr, this.parentNote)))) { return true; } }