You are here

private function GeofieldMapFieldTrait::setMapAdditionalOptionsElement in Geofield Map 8.2

Same name and namespace in other branches
  1. 8 src/GeofieldMapFieldTrait.php \Drupal\geofield_map\GeofieldMapFieldTrait::setMapAdditionalOptionsElement()

Set Map Additional Options Element.

Parameters

array $settings: The Form Settings.

array $elements: The Form element to alter.

1 call to GeofieldMapFieldTrait::setMapAdditionalOptionsElement()
GeofieldMapFieldTrait::generateGmapSettingsForm in src/GeofieldMapFieldTrait.php
Generate the Google Map Settings Form.

File

src/GeofieldMapFieldTrait.php, line 1081

Class

GeofieldMapFieldTrait
Class GeofieldMapFieldTrait.

Namespace

Drupal\geofield_map

Code

private function setMapAdditionalOptionsElement(array $settings, array &$elements) {
  $elements['map_additional_options'] = [
    '#type' => 'textarea',
    '#rows' => 5,
    '#title' => $this
      ->t('Map Additional Options'),
    '#description' => $this
      ->t('<strong>These will override the above settings</strong><br>An object literal of additional map options, that comply with the Google Maps JavaScript API.<br>The syntax should respect the javascript object notation (json) format.<br>As suggested in the field placeholder, always use double quotes (") both for the indexes and the string values.<br>It is even possible to input Map Control Positions. For this use the numeric values of the google.maps.ControlPosition, otherwise the option will be passed as incomprehensible string to Google Maps API.'),
    '#default_value' => $settings['map_additional_options'],
    '#placeholder' => '{"disableDoubleClickZoom": "cooperative",
"gestureHandling": "none",
"streetViewControlOptions": {"position": 5}
      }',
    '#element_validate' => [
      [
        get_class($this),
        'jsonValidate',
      ],
    ],
  ];
  $elements['map_additional_libraries'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Map additional Libraries'),
    '#description' => $this
      ->t('Select the additional @libraries_link that should be included with the Google Maps library request.', [
      '@libraries_link' => $this->link
        ->generate('Google Map Libraries', Url::fromUri('https://developers.google.com/maps/documentation/javascript/drawinglayer', [
        'absolute' => TRUE,
        'attributes' => [
          'target' => 'blank',
        ],
      ])),
    ]),
    '#default_value' => $settings['map_additional_libraries'],
    '#options' => [
      'places' => $this
        ->t('Places'),
      'drawing' => $this
        ->t('Drawing'),
      'geometry' => $this
        ->t('Geometry'),
      'visualization' => $this
        ->t('Visualization'),
    ],
  ];
}