You are here

protected function YamapsDefaultWidget::addPolygonsToMap in Yandex.Maps 8

Add polygons to map and enable tool.

Parameters

array $elements:

$map_id:

$placemarks:

1 call to YamapsDefaultWidget::addPolygonsToMap()
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 103

Class

YamapsDefaultWidget
Plugin implementation of the 'yamaps_default' widget.

Namespace

Drupal\yamaps\Plugin\Field\FieldWidget

Code

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