public function LeafletWidgetSettingsTrait::getWidgetSettingsForm in Leaflet Widget for Geofield 8.2
1 call to LeafletWidgetSettingsTrait::getWidgetSettingsForm()
- LeafletWidget::settingsForm in src/
Plugin/ Field/ FieldWidget/ LeafletWidget.php - Returns a form to configure settings for the widget.
File
- src/
LeafletWidgetSettingsTrait.php, line 51
Class
- LeafletWidgetSettingsTrait
- Trait LeafletWidgetSettingsTrait.
Namespace
Drupal\leaflet_widgetCode
public function getWidgetSettingsForm(array $form) {
$map_settings = $this
->getSetting('map');
$form['map'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Map Settings'),
];
$form['map']['leaflet_map'] = [
'#title' => $this
->t('Leaflet Map'),
'#type' => 'select',
'#options' => [
'' => $this
->t('-- Empty --'),
] + $this
->getLeafletMaps(),
'#default_value' => $map_settings['leaflet_map'],
'#required' => TRUE,
];
$form['map']['height'] = [
'#title' => $this
->t('Height'),
'#type' => 'textfield',
'#required' => TRUE,
'#default_value' => $map_settings['height'],
];
$form['map']['center'] = [
'#type' => 'fieldset',
'#collapsed' => TRUE,
'#collapsible' => TRUE,
'#title' => 'Default map center',
];
$form['map']['center']['lat'] = [
'#type' => 'textfield',
'#title' => $this
->t('Latitude'),
'#default_value' => $map_settings['center']['lat'],
'#required' => TRUE,
];
$form['map']['center']['lon'] = [
'#type' => 'textfield',
'#title' => $this
->t('Longtitude'),
'#default_value' => $map_settings['center']['lon'],
'#required' => TRUE,
];
$form['map']['auto_center'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Automatically center map on existing features'),
'#description' => t("This option overrides the widget's default center."),
'#default_value' => $map_settings['auto_center'],
];
$form['map']['zoom'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default zoom level'),
'#default_value' => $map_settings['zoom'],
'#required' => TRUE,
];
$form['map']['locate'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Automatically locate user current position'),
'#description' => t("This option centers the map to the user position."),
'#default_value' => $map_settings['locate'],
];
$form['map']['scroll_zoom_enabled'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable Scroll Wheel Zoom on click'),
'#description' => t("This option enables zooming by mousewheel as soon as the user clicked on the map."),
'#default_value' => $map_settings['scroll_zoom_enabled'],
];
$form['map']['fullscreen_control'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Fullscreen Control'),
'#description' => $this
->t('Enable the Fullscreen View of the Map.'),
'#default_value' => $map_settings['fullscreen_control'],
'#return_value' => 1,
];
$input_settings = $this
->getSetting('input');
$form['input'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Geofield Settings'),
];
$form['input']['show'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show geofield input element'),
'#default_value' => $input_settings['show'],
];
$form['input']['readonly'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Make geofield input element read-only'),
'#default_value' => $input_settings['readonly'],
'#states' => [
'invisible' => [
':input[name="fields[field_geofield][settings_edit_form][settings][input][show]"]' => [
'checked' => FALSE,
],
],
],
];
$toolbar_settings = $this
->getSetting('toolbar');
$form['toolbar'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Leaflet PM Settings'),
];
$form['toolbar']['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'),
],
'#default_value' => $toolbar_settings['position'],
];
$form['toolbar']['drawMarker'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Adds button to draw markers.'),
'#default_value' => $toolbar_settings['drawMarker'],
];
$form['toolbar']['drawPolyline'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Adds button to draw polyline.'),
'#default_value' => $toolbar_settings['drawPolyline'],
];
$form['toolbar']['drawRectangle'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Adds button to draw rectangle.'),
'#default_value' => $toolbar_settings['drawRectangle'],
];
$form['toolbar']['drawPolygon'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Adds button to draw polygon.'),
'#default_value' => $toolbar_settings['drawPolygon'],
];
$form['toolbar']['drawCircle'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Adds button to draw circle. (unsupported by GeoJSON'),
'#default_value' => $toolbar_settings['drawCircle'],
'#disabled' => TRUE,
];
$form['toolbar']['drawCircleMarker'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Adds button to draw circle marker. (unsupported by GeoJSON'),
'#default_value' => $toolbar_settings['drawCircleMarker'],
'#disabled' => TRUE,
];
$form['toolbar']['editMode'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Adds button to toggle edit mode for all layers.'),
'#default_value' => $toolbar_settings['editMode'],
];
$form['toolbar']['dragMode'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Adds button to toggle drag mode for all layers.'),
'#default_value' => $toolbar_settings['dragMode'],
];
$form['toolbar']['cutPolygon'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Adds button to cut hole in polygon.'),
'#default_value' => $toolbar_settings['cutPolygon'],
];
$form['toolbar']['removalMode'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Adds button to remove layers.'),
'#default_value' => $toolbar_settings['removalMode'],
];
return $form;
}