You are here

public function GeolocationGpx::getSettingsForm in Geolocation Field 8.3

Provide data provider settings form array.

Parameters

array $settings: The current data provider settings.

array $parents: Form parents.

Return value

array A form array to be integrated in whatever.

Overrides DataProviderBase::getSettingsForm

File

modules/geolocation_gpx/src/Plugin/geolocation/DataProvider/GeolocationGpx.php, line 68

Class

GeolocationGpx
Provides GPX.

Namespace

Drupal\geolocation_gpx\Plugin\geolocation\DataProvider

Code

public function getSettingsForm(array $settings, array $parents = []) {
  $element = parent::getSettingsForm($settings, $parents);
  $settings = $this
    ->getSettings($settings);
  if (!empty($this->viewsField)) {
    $form_parent = "style_options[data_provider_settings]";
  }
  elseif (!empty($this->fieldDefinition)) {
    $form_parent = "fields['" . $this->fieldDefinition
      ->getName() . "'][settings_edit_form][settings]";
  }
  else {
    $form_parent = '';
  }
  $element['return_tracks'] = [
    '#weight' => -99,
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Add tracks'),
    '#description' => $this
      ->t('Will be displayed as polylines; names should show up on hover/click.'),
    '#default_value' => $settings['return_tracks'],
  ];
  $element['return_waypoints'] = [
    '#weight' => -100,
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Add waypoints'),
    '#description' => $this
      ->t('Will be displayed as regular markers, with the name as marker title.'),
    '#default_value' => $settings['return_waypoints'],
  ];
  $element['return_track_locations'] = [
    '#weight' => -100,
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Add raw track locations'),
    '#default_value' => $settings['return_track_locations'],
  ];
  $element['return_waypoint_locations'] = [
    '#weight' => -100,
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Add raw waypoint locations'),
    '#default_value' => $settings['return_waypoint_locations'],
  ];
  $element['track_stroke_color'] = [
    '#weight' => -98,
    '#type' => 'color',
    '#title' => $this
      ->t('Track color'),
    '#default_value' => $settings['track_stroke_color'],
    '#states' => [
      'visible' => [
        ':input[name="' . $form_parent . '[return_tracks]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $element['track_stroke_color_randomize'] = [
    '#weight' => -98,
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Randomize track colors'),
    '#default_value' => $settings['track_stroke_color_randomize'],
    '#states' => [
      'visible' => [
        ':input[name="' . $form_parent . '[return_tracks]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $element['track_stroke_width'] = [
    '#weight' => -98,
    '#type' => 'number',
    '#title' => $this
      ->t('Track Width'),
    '#description' => $this
      ->t('Width of the tracks in pixels.'),
    '#default_value' => $settings['track_stroke_width'],
    '#states' => [
      'visible' => [
        ':input[name="' . $form_parent . '[return_tracks]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $element['track_stroke_opacity'] = [
    '#weight' => -98,
    '#type' => 'number',
    '#step' => 0.01,
    '#title' => $this
      ->t('Track Opacity'),
    '#description' => $this
      ->t('Opacity of the tracks from 1 = fully visible, 0 = complete see through.'),
    '#default_value' => $settings['track_stroke_opacity'],
    '#states' => [
      'visible' => [
        ':input[name="' . $form_parent . '[return_tracks]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  return $element;
}