@@ -20,6 +20,13 @@ class WebformLeafletMapField extends WebformElementBase {
2020
2121 use LeafletSettingsElementsTrait;
2222
23+ // Valid Leaflet control positions (cf.
24+ // https://github.com/Leaflet/Leaflet/blob/main/src/control/Control.js).
25+ const string LEAFLET_POSITION_TOP_LEFT = 'topleft ' ;
26+ const string LEAFLET_POSITION_TOP_RIGHT = 'topright ' ;
27+ const string LEAFLET_POSITION_BOTTOM_LEFT = 'bottomleft ' ;
28+ const string LEAFLET_POSITION_BOTTOM_RIGHT = 'bottomright ' ;
29+
2330 /**
2431 * {@inheritdoc}
2532 */
@@ -33,10 +40,11 @@ public function defineDefaultProperties(): array {
3340 'minZoom ' => 1 ,
3441 'maxZoom ' => 18 ,
3542 'zoomFiner ' => 0 ,
43+ 'zoomControlPosition ' => self ::LEAFLET_POSITION_TOP_LEFT ,
3644 'scrollWheelZoom ' => 0 ,
3745 'doubleClickZoom ' => 1 ,
3846
39- 'position ' => ' topleft ' ,
47+ 'position ' => self :: LEAFLET_POSITION_TOP_LEFT ,
4048 'marker ' => 'defaultMarker ' ,
4149 'drawPolyline ' => 0 ,
4250 'drawRectangle ' => 0 ,
@@ -72,6 +80,13 @@ public function form(array $form, FormStateInterface $form_state) {
7280 $ form = parent ::form ($ form , $ form_state );
7381 $ map_keys = array_keys (leaflet_map_get_info ());
7482
83+ $ positionOptions = [
84+ self ::LEAFLET_POSITION_TOP_LEFT => $ this ->t ('topleft ' ),
85+ self ::LEAFLET_POSITION_TOP_RIGHT => $ this ->t ('topright ' ),
86+ self ::LEAFLET_POSITION_BOTTOM_LEFT => $ this ->t ('bottomleft ' ),
87+ self ::LEAFLET_POSITION_BOTTOM_RIGHT => $ this ->t ('bottomright ' ),
88+ ];
89+
7590 $ form ['mapstyles ' ] = [
7691 '#type ' => 'fieldset ' ,
7792 '#title ' => $ this ->t ('Map settings ' ),
@@ -139,6 +154,11 @@ public function form(array $form, FormStateInterface $form_state) {
139154 '#step ' => 1 ,
140155 '#description ' => $ this ->t ('Value that might/will be added to default Fit Elements Bounds Zoom. (-5 / +5) ' ),
141156 ],
157+ 'zoomControlPosition ' => [
158+ '#type ' => 'select ' ,
159+ '#title ' => $ this ->t ('Zoom control position ' ),
160+ '#options ' => $ positionOptions ,
161+ ],
142162 'scrollWheelZoom ' => [
143163 '#type ' => 'checkbox ' ,
144164 '#title ' => $ this ->t ('Enable Scroll Wheel Zoom on click ' ),
@@ -159,12 +179,7 @@ public function form(array $form, FormStateInterface $form_state) {
159179 'position ' => [
160180 '#type ' => 'select ' ,
161181 '#title ' => $ this ->t ('Toolbar position. ' ),
162- '#options ' => [
163- 'topleft ' => $ this ->t ('topleft ' ),
164- 'topright ' => $ this ->t ('topright ' ),
165- 'bottomleft ' => $ this ->t ('bottomleft ' ),
166- 'bottomright ' => $ this ->t ('bottomright ' ),
167- ],
182+ '#options ' => $ positionOptions ,
168183 ],
169184 'marker ' => [
170185 '#type ' => 'radios ' ,
0 commit comments