You are here

protected function LeafletSettingsElementsTrait::setMapPathOptionsElement in Leaflet 8

Same name and namespace in other branches
  1. 2.1.x src/LeafletSettingsElementsTrait.php \Drupal\leaflet\LeafletSettingsElementsTrait::setMapPathOptionsElement()
  2. 2.0.x src/LeafletSettingsElementsTrait.php \Drupal\leaflet\LeafletSettingsElementsTrait::setMapPathOptionsElement()

Set Map Geometries Options Element.

Parameters

array $element: The Form element to alter.

array $settings: The Form Settings.

2 calls to LeafletSettingsElementsTrait::setMapPathOptionsElement()
LeafletDefaultFormatter::settingsForm in src/Plugin/Field/FieldFormatter/LeafletDefaultFormatter.php
Returns a form to configure settings for the formatter.
LeafletMap::buildOptionsForm in modules/leaflet_views/src/Plugin/views/style/LeafletMap.php
Provide a form to edit options for this plugin.

File

src/LeafletSettingsElementsTrait.php, line 613

Class

LeafletSettingsElementsTrait
Class GeofieldMapFieldTrait.

Namespace

Drupal\leaflet

Code

protected function setMapPathOptionsElement(array &$element, array $settings) {
  $token_replacement_disclaimer = $this
    ->t('<b>Note: </b> Using <strong>Replacement Patterns</strong> it is possible to dynamically define the Path geometries options, based on the entity properties or fields values.');
  $path_description = $this
    ->t('Set here options that will be applied to the rendering of Map Path Geometries (Lines & Polylines, Polygons, Multipolygons, etc.).<br>Refer to the @polygons_documentation.<br>Note: If empty the default Leaflet path style, or the one choosen and defined in leaflet.api/hook_leaflet_map_info, will be used.<br>@token_replacement_disclaimer', [
    '@polygons_documentation' => $this->link
      ->generate($this
      ->t('Leaflet Path Documentation'), Url::fromUri('https://leafletjs.com/reference-1.0.3.html#path', [
      'absolute' => TRUE,
      'attributes' => [
        'target' => 'blank',
      ],
    ])),
    '@token_replacement_disclaimer' => $token_replacement_disclaimer,
  ]);
  $element['path'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Path Geometries Options'),
    '#rows' => 3,
    '#description' => $path_description,
    '#default_value' => $settings['path'],
    '#placeholder' => $this::getDefaultSettings()['path'],
    '#element_validate' => [
      [
        get_class($this),
        'jsonValidate',
      ],
    ],
  ];
}