You are here

public function LeafletMarkerIcon::getSettingsForm in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/LeafletMarkerIcon.php \Drupal\geolocation_leaflet\Plugin\geolocation\MapFeature\LeafletMarkerIcon::getSettingsForm()

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 MapFeatureBase::getSettingsForm

File

modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/LeafletMarkerIcon.php, line 53

Class

LeafletMarkerIcon
Provides marker icon adjustment.

Namespace

Drupal\geolocation_leaflet\Plugin\geolocation\MapFeature

Code

public function getSettingsForm(array $settings, array $parents) {
  $settings = $this
    ->getSettings($settings);
  $form['marker_icon_path'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Icon path'),
    '#description' => $this
      ->t('Set relative or absolute path to custom marker icon. Tokens supported. Empty for default. Attention: In views contexts, additional icon source options are available in the style settings.'),
    '#default_value' => $settings['marker_icon_path'],
  ];
  $form['icon_size'] = [
    '#type' => 'item',
    '#description' => $this
      ->t('Size of the icon image in pixels.'),
    'width' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Icon Size - Width'),
      '#default_value' => $settings['icon_size']['width'],
      '#min' => 0,
    ],
    'height' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Icon Size - Height'),
      '#default_value' => $settings['icon_size']['height'],
      '#min' => 0,
    ],
  ];
  $form['icon_anchor'] = [
    '#type' => 'item',
    '#description' => $this
      ->t('The coordinates of the "tip" of the icon (relative to its top left corner). The icon will be aligned so that this point is at the marker\'s geographical location. Centered by default if size is specified.'),
    'x' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Icon Anchor - X'),
      '#default_value' => $settings['icon_anchor']['x'],
    ],
    'y' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Icon Anchor - Y'),
      '#default_value' => $settings['icon_anchor']['y'],
    ],
  ];
  $form['popup_anchor'] = [
    '#type' => 'item',
    '#description' => $this
      ->t('The coordinates of the point from which popups will "open", relative to the icon anchor.'),
    'x' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Popup Anchor - X'),
      '#default_value' => $settings['popup_anchor']['x'],
    ],
    'y' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Popup Anchor - Y'),
      '#default_value' => $settings['popup_anchor']['y'],
    ],
  ];
  $form['marker_shadow_path'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Shadow path'),
    '#description' => $this
      ->t('Set relative or absolute path to custom marker shadow. Tokens supported. Empty for default. Attention: In views contexts, additional shadow source options are available in the style settings.'),
    '#default_value' => $settings['marker_shadow_path'],
  ];
  $form['shadow_size'] = [
    '#type' => 'item',
    '#description' => $this
      ->t('Size of the shadow image in pixels.'),
    'width' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Shadow Size - Width'),
      '#default_value' => $settings['shadow_size']['width'],
      '#min' => 0,
    ],
    'height' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Shadow Size - Height'),
      '#default_value' => $settings['shadow_size']['height'],
      '#min' => 0,
    ],
  ];
  $form['shadow_anchor'] = [
    '#type' => 'item',
    '#description' => $this
      ->t('The coordinates of the "tip" of the shadow (relative to its top left corner) (the same as iconAnchor if not specified).'),
    'x' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Shadow Anchor - X'),
      '#default_value' => $settings['shadow_anchor']['x'],
    ],
    'y' => [
      '#type' => 'number',
      '#title' => $this
        ->t('Shadow Anchor - Y'),
      '#default_value' => $settings['shadow_anchor']['y'],
    ],
  ];
  return $form;
}