public function ControlDirections::getSettingsForm in Geolocation Field 8.3
Provide a generic map settings form array.
Parameters
array $settings: The current map settings.
array $parents: Form specific optional prefix.
Return value
array A form array to be integrated in whatever.
Overrides ControlGoogleElementBase::getSettingsForm
File
- modules/
geolocation_google_maps/ src/ Plugin/ geolocation/ MapFeature/ ControlDirections.php, line 43
Class
- ControlDirections
- Provides Directions Service.
Namespace
Drupal\geolocation_google_maps\Plugin\geolocation\MapFeatureCode
public function getSettingsForm(array $settings, array $parents) {
$states_prefix = array_shift($parents) . '[' . implode('][', $parents) . ']';
$form = parent::getSettingsForm($settings, $parents);
$form['origin_source'] = [
'#type' => 'select',
'#title' => $this
->t('Origin source'),
'#options' => [
'exposed' => $this
->t('Exposed textfield for user.'),
'static' => $this
->t('Static value'),
],
'#description' => $this
->t('Origin point for directions.'),
'#default_value' => $settings['origin_source'],
];
$form['origin_static_value'] = [
'#type' => 'textfield',
'#title' => $this
->t('Static origin'),
'#description' => $this
->t('Enter an address or coordinates as "lat, lng". Tokens supported.'),
'#default_value' => $settings['origin_static_value'],
'#states' => [
'visible' => [
'select[name="' . $states_prefix . '[origin_source]"]' => [
'value' => 'static',
],
],
],
];
$form['destination_source'] = [
'#type' => 'select',
'#title' => $this
->t('Destination source'),
'#options' => [
'exposed' => $this
->t('Exposed textfield for user.'),
'static' => $this
->t('Static value'),
],
'#description' => $this
->t('Destination point for directions.'),
'#default_value' => $settings['destination_source'],
];
$form['destination_static_value'] = [
'#type' => 'textfield',
'#title' => $this
->t('Static destination'),
'#description' => $this
->t('Enter an address or coordinates as "lat, lng". Tokens supported.'),
'#default_value' => $settings['destination_static_value'],
'#states' => [
'visible' => [
'select[name="' . $states_prefix . '[destination_source]"]' => [
'value' => 'static',
],
],
],
];
$form['travel_mode'] = [
'#type' => 'select',
'#title' => $this
->t('Travel mode'),
'#options' => [
'exposed' => $this
->t('Exposed'),
'driving' => $this
->t('Driving'),
'walking' => $this
->t('Walking'),
'bicycling' => $this
->t('Bicycling'),
'transit' => $this
->t('Transit'),
],
'#default_value' => $settings['travel_mode'],
];
$form['directions_container'] = [
'#type' => 'select',
'#title' => $this
->t('Directions container'),
'#options' => [
'above' => $this
->t('Attach above map.'),
'below' => $this
->t('Attach below map'),
'custom' => $this
->t('Inject to custom Element by #ID'),
],
'#default_value' => $settings['directions_container'],
];
$form['directions_container_custom_id'] = [
'#type' => 'textfield',
'#title' => $this
->t('Directions custom container #ID'),
'#default_value' => $settings['directions_container_custom_id'],
'#states' => [
'visible' => [
'select[name="' . $states_prefix . '[directions_container]"]' => [
'value' => 'custom',
],
],
],
];
return $form;
}