GeolocationYandexWidget.php in Geolocation Field 8.3
File
modules/geolocation_yandex/src/Plugin/Field/FieldWidget/GeolocationYandexWidget.php
View source
<?php
namespace Drupal\geolocation_yandex\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\geolocation\Plugin\Field\FieldWidget\GeolocationMapWidgetBase;
use Drupal\Core\Render\BubbleableMetadata;
class GeolocationYandexWidget extends GeolocationMapWidgetBase {
protected static $mapProviderId = 'yandex';
protected static $mapProviderSettingsFormId = 'yandex_settings';
public static function defaultSettings() {
$settings = parent::defaultSettings();
$settings[self::$mapProviderSettingsFormId]['map_features']['yandex_control_search'] = [
'enabled' => TRUE,
'weight' => -100,
];
$settings[self::$mapProviderSettingsFormId]['map_features']['yandex_control_zoom']['enabled'] = TRUE;
$settings[self::$mapProviderSettingsFormId]['map_features']['yandex_control_geolocation']['enabled'] = TRUE;
return $settings;
}
public function form(FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta = NULL) {
$element = parent::form($items, $form, $form_state, $get_delta);
$element['#attributes']['data-widget-type'] = 'yandex';
$element['#attached'] = BubbleableMetadata::mergeAttachments($element['#attached'], [
'library' => [
'geolocation_yandex/widget.yandex',
],
]);
return $element;
}
}