private function GeofieldMapFieldTrait::setMapControlsElement in Geofield Map 8
Same name and namespace in other branches
- 8.2 src/GeofieldMapFieldTrait.php \Drupal\geofield_map\GeofieldMapFieldTrait::setMapControlsElement()
Set Map Control Element.
Parameters
array $settings: The Form Settings.
array $elements: The Form element to alter.
1 call to GeofieldMapFieldTrait::setMapControlsElement()
- GeofieldMapFieldTrait::generateGmapSettingsForm in src/
GeofieldMapFieldTrait.php - Generate the Google Map Settings Form.
File
- src/
GeofieldMapFieldTrait.php, line 600
Class
- GeofieldMapFieldTrait
- Class GeofieldMapFieldTrait.
Namespace
Drupal\geofield_mapCode
private function setMapControlsElement(array $settings, array &$elements) {
if (isset($this->fieldDefinition)) {
$disable_default_ui_selector = ':input[name="fields[' . $this->fieldDefinition
->getName() . '][settings_edit_form][settings][map_controls][disable_default_ui]"]';
}
else {
$disable_default_ui_selector = ':input[name="style_options[map_controls][disable_default_ui]"]';
}
$elements['map_controls'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Map Controls'),
];
$elements['map_controls']['disable_default_ui'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Disable Default UI'),
'#description' => $this
->t('This property disables any automatic UI behavior and Control from the Google Map'),
'#default_value' => $settings['map_controls']['disable_default_ui'],
'#return_value' => 1,
];
$elements['map_controls']['zoom_control'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Zoom Control'),
'#description' => $this
->t('The enabled/disabled state of the Zoom control.'),
'#default_value' => $settings['map_controls']['zoom_control'],
'#return_value' => 1,
'#states' => [
'visible' => [
$disable_default_ui_selector => [
'checked' => FALSE,
],
],
],
];
$elements['map_controls']['map_type_id'] = [
'#type' => 'select',
'#title' => $this
->t('Default Map Type'),
'#default_value' => $settings['map_controls']['map_type_id'],
'#options' => $this->gMapTypesOptions,
];
$elements['map_controls']['map_type_control'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enabled Map Type Control'),
'#description' => $this
->t('The initial enabled/disabled state of the Map type control.'),
'#default_value' => $settings['map_controls']['map_type_control'],
'#return_value' => 1,
'#states' => [
'visible' => [
$disable_default_ui_selector => [
'checked' => FALSE,
],
],
],
];
$elements['map_controls']['map_type_control_options_type_ids'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('The enabled Map Types'),
'#description' => $this
->t('The Map Types that will be available in the Map Type Control.'),
'#default_value' => $settings['map_controls']['map_type_control_options_type_ids'],
'#options' => $this->gMapTypesOptions,
'#return_value' => 1,
];
if (isset($this->fieldDefinition)) {
$elements['map_controls']['map_type_control_options_type_ids']['#states'] = [
'invisible' => [
[
':input[name="fields[' . $this->fieldDefinition
->getName() . '][settings_edit_form][settings][map_controls][map_type_control]"]' => [
'checked' => FALSE,
],
],
[
$disable_default_ui_selector => [
'checked' => TRUE,
],
],
],
];
}
else {
$elements['map_controls']['map_type_control_options_type_ids']['#states'] = [
'invisible' => [
[
':input[name="style_options[map_controls][map_type_control]"]' => [
'checked' => FALSE,
],
],
[
$disable_default_ui_selector => [
'checked' => TRUE,
],
],
],
];
}
$elements['map_controls']['scale_control'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Scale Control'),
'#description' => $this
->t('Show map scale'),
'#default_value' => $settings['map_controls']['scale_control'],
'#return_value' => 1,
'#states' => [
'visible' => [
$disable_default_ui_selector => [
'checked' => FALSE,
],
],
],
];
$elements['map_controls']['street_view_control'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Streetview Control'),
'#description' => $this
->t('Enable the Street View functionality on the Map.'),
'#default_value' => $settings['map_controls']['street_view_control'],
'#return_value' => 1,
'#states' => [
'visible' => [
$disable_default_ui_selector => [
'checked' => FALSE,
],
],
],
];
$elements['map_controls']['fullscreen_control'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Fullscreen Control'),
'#description' => $this
->t('Enable the Fullscreen View of the Map.'),
'#default_value' => $settings['map_controls']['fullscreen_control'],
'#return_value' => 1,
'#states' => [
'visible' => [
$disable_default_ui_selector => [
'checked' => FALSE,
],
],
],
];
}