From 5efb744a21cdb75569a18771d81f1bbfd1e76771 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 3 Feb 2026 10:34:38 +0100 Subject: [PATCH 1/3] Added required "Zoom control position" to map element --- .../src/Element/WebformLeafletMapField.php | 1 + .../WebformElement/WebformLeafletMapField.php | 29 ++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/modules/os2forms_webform_maps/src/Element/WebformLeafletMapField.php b/modules/os2forms_webform_maps/src/Element/WebformLeafletMapField.php index 87b079d0..84f7506c 100644 --- a/modules/os2forms_webform_maps/src/Element/WebformLeafletMapField.php +++ b/modules/os2forms_webform_maps/src/Element/WebformLeafletMapField.php @@ -90,6 +90,7 @@ public static function processWebformMapElement(&$element, FormStateInterface $f 'zoomFiner' => $element['#zoomFiner'], 'minZoom' => $element['#minZoom'], 'maxZoom' => $element['#maxZoom'], + 'zoomControlPosition' => $element['#zoomControlPosition'] ?? 'topleft', 'center' => [ 'lat' => (float) $element['#lat'], 'lon' => (float) $element['#lon'], diff --git a/modules/os2forms_webform_maps/src/Plugin/WebformElement/WebformLeafletMapField.php b/modules/os2forms_webform_maps/src/Plugin/WebformElement/WebformLeafletMapField.php index d6a5afea..31374ba7 100644 --- a/modules/os2forms_webform_maps/src/Plugin/WebformElement/WebformLeafletMapField.php +++ b/modules/os2forms_webform_maps/src/Plugin/WebformElement/WebformLeafletMapField.php @@ -20,6 +20,13 @@ class WebformLeafletMapField extends WebformElementBase { use LeafletSettingsElementsTrait; + // Valid Leaflet control positions (cf. + // https://github.com/Leaflet/Leaflet/blob/main/src/control/Control.js). + private const string LEAFLET_POSITION_TOP_LEFT = 'topleft'; + private const string LEAFLET_POSITION_TOP_RIGHT = 'topright'; + private const string LEAFLET_POSITION_BOTTOM_LEFT = 'bottomleft'; + private const string LEAFLET_POSITION_BOTTOM_RIGHT = 'bottomright'; + /** * {@inheritdoc} */ @@ -33,10 +40,11 @@ public function defineDefaultProperties(): array { 'minZoom' => 1, 'maxZoom' => 18, 'zoomFiner' => 0, + 'zoomControlPosition' => self::LEAFLET_POSITION_TOP_LEFT, 'scrollWheelZoom' => 0, 'doubleClickZoom' => 1, - 'position' => 'topleft', + 'position' => self::LEAFLET_POSITION_TOP_LEFT, 'marker' => 'defaultMarker', 'drawPolyline' => 0, 'drawRectangle' => 0, @@ -72,6 +80,13 @@ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $map_keys = array_keys(leaflet_map_get_info()); + $positionOptions = [ + self::LEAFLET_POSITION_TOP_LEFT => $this->t('topleft'), + self::LEAFLET_POSITION_TOP_RIGHT => $this->t('topright'), + self::LEAFLET_POSITION_BOTTOM_LEFT => $this->t('bottomleft'), + self::LEAFLET_POSITION_BOTTOM_RIGHT => $this->t('bottomright'), + ]; + $form['mapstyles'] = [ '#type' => 'fieldset', '#title' => $this->t('Map settings'), @@ -139,6 +154,11 @@ public function form(array $form, FormStateInterface $form_state) { '#step' => 1, '#description' => $this->t('Value that might/will be added to default Fit Elements Bounds Zoom. (-5 / +5)'), ], + 'zoomControlPosition' => [ + '#type' => 'select', + '#title' => $this->t('Zoom control position'), + '#options' => $positionOptions, + ], 'scrollWheelZoom' => [ '#type' => 'checkbox', '#title' => $this->t('Enable Scroll Wheel Zoom on click'), @@ -159,12 +179,7 @@ public function form(array $form, FormStateInterface $form_state) { 'position' => [ '#type' => 'select', '#title' => $this->t('Toolbar position.'), - '#options' => [ - 'topleft' => $this->t('topleft'), - 'topright' => $this->t('topright'), - 'bottomleft' => $this->t('bottomleft'), - 'bottomright' => $this->t('bottomright'), - ], + '#options' => $positionOptions, ], 'marker' => [ '#type' => 'radios', From 76a63ba263ab1eb304e1d8f0408e39277b91a676 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 3 Feb 2026 10:38:47 +0100 Subject: [PATCH 2/3] Removed reference to nonexistent CSS file --- .../os2forms_webform_maps/os2forms_webform_maps.libraries.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/os2forms_webform_maps/os2forms_webform_maps.libraries.yml b/modules/os2forms_webform_maps/os2forms_webform_maps.libraries.yml index c223f6c3..78ce35dd 100644 --- a/modules/os2forms_webform_maps/os2forms_webform_maps.libraries.yml +++ b/modules/os2forms_webform_maps/os2forms_webform_maps.libraries.yml @@ -1,8 +1,5 @@ webformmap: version: 1.x - css: - theme: - css/webform_map.css: {} js: js/webform_map.js: {} dependencies: From c46ffda776ac31d32c9e2d2ea5847eafc8d68ee2 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 3 Feb 2026 10:41:06 +0100 Subject: [PATCH 3/3] Updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6f3e756..53ef51fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ before starting to add changes. Use example [placed in the end of the page](#exa ## [Unreleased] +- [PR-289](https://github.com/OS2Forms/os2forms/pull/289) + Added required "Zoom control position" to map element + ## [5.0.0] 2025-11-18 - [PR-192](https://github.com/OS2Forms/os2forms/pull/192)