You are here

protected function YamapsDefaultWidget::addPlacemarksToMap in Yandex.Maps 8

Add placemarks to map and enable tool.

Parameters

array $elements:

$map_id:

$placemarks:

1 call to YamapsDefaultWidget::addPlacemarksToMap()
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 61

Class

YamapsDefaultWidget
Plugin implementation of the 'yamaps_default' widget.

Namespace

Drupal\yamaps\Plugin\Field\FieldWidget

Code

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