You are here

protected function YamapsDefaultWidget::addLinesToMap in Yandex.Maps 8

Add lines to map and enable tool.

Parameters

array $elements:

$map_id:

$placemarks:

1 call to YamapsDefaultWidget::addLinesToMap()
YamapsDefaultWidget::formElement in src/Plugin/Field/FieldWidget/YamapsDefaultWidget.php
Returns the form for a single field widget.

File

src/Plugin/Field/FieldWidget/YamapsDefaultWidget.php, line 82

Class

YamapsDefaultWidget
Plugin implementation of the 'yamaps_default' widget.

Namespace

Drupal\yamaps\Plugin\Field\FieldWidget

Code

protected function addLinesToMap(array &$element, $map_id, $lines) {
  $element['lines'] = [
    '#type' => 'hidden',
    '#default_value' => $lines,
    '#attributes' => [
      'class' => [
        'field-yamaps-lines-' . $map_id,
      ],
    ],
  ];
  if ($this
    ->getFieldSetting('enable_lines')) {
    $element['#attached']['library'][] = 'yamaps/yamaps-line';
    $this->map['lines'] = Json::decode($lines);
  }
}