You are here

public function GeofieldMapFieldTrait::generateGmapSettingsForm in Geofield Map 8

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

Generate the Google Map Settings Form.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

array $settings: Form settings.

array $default_settings: Default settings.

Return value

array The GMap Settings Form

1 call to GeofieldMapFieldTrait::generateGmapSettingsForm()
GeofieldGoogleMapViewStyle::buildOptionsForm in src/Plugin/views/style/GeofieldGoogleMapViewStyle.php
Provide a form to edit options for this plugin.

File

src/GeofieldMapFieldTrait.php, line 160

Class

GeofieldMapFieldTrait
Class GeofieldMapFieldTrait.

Namespace

Drupal\geofield_map

Code

public function generateGmapSettingsForm(array $form, FormStateInterface $form_state, array $settings, array $default_settings) {
  $elements = [];

  // Attach Geofield Map Library.
  $elements['#attached']['library'] = [
    'geofield_map/geofield_map_general',
  ];

  // Set Google Api Key Element.
  $this
    ->setMapGoogleApiKeyElement($elements);

  // Set Map Dimension Element.
  $this
    ->setMapDimensionsElement($settings, $elements);

  // Set Map Empty Options Element.
  $this
    ->setMapEmptyElement($settings, $elements);
  $elements['gmaps_api_link_markup'] = [
    '#markup' => $this
      ->t('The following settings comply with the @gmaps_api_link.', [
      '@gmaps_api_link' => $this->link
        ->generate($this
        ->t('Google Maps JavaScript API Library'), Url::fromUri('https://developers.google.com/maps/documentation/javascript', [
        'absolute' => TRUE,
        'attributes' => [
          'target' => 'blank',
        ],
      ])),
    ]),
  ];

  // Set Map Center Element.
  $this
    ->setMapCenterElement($settings, $elements);

  // Set Map Zoom and Pan Element.
  $this
    ->setMapZoomAndPanElement($settings, $default_settings, $elements);

  // Set Map Control Element.
  $this
    ->setMapControlsElement($settings, $elements);

  // Set Map Marker and Infowindow Element.
  $this
    ->setMapMarkerAndInfowindowElement($form, $settings, $elements);

  // Set Map Additional Options Element.
  $this
    ->setMapAdditionalOptionsElement($settings, $elements);

  // Set Overlapping Marker Spiderfier Element.
  $this
    ->setMapOmsElement($settings, $default_settings, $elements);

  // Set Custom Map Style Element.
  $this
    ->setCustomStyleMapElement($settings, $elements);

  // Set Map Marker Cluster Element.
  $this
    ->setMapMarkerclusterElement($settings, $elements);
  return $elements;
}