You are here

public function GeofieldMapFieldTrait::generateGmapSettingsForm in Geofield Map 8.2

Same name and namespace in other branches
  1. 8 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 215

Class

GeofieldMapFieldTrait
Class GeofieldMapFieldTrait.

Namespace

Drupal\geofield_map

Code

public function generateGmapSettingsForm(array $form, FormStateInterface $form_state, array $settings, array $default_settings) {
  $elements['#attached'] = [
    'library' => [
      'geofield_map/geofield_map_view_display_settings',
    ],
  ];
  $elements = [];

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

  // Set Google Api Key Element.
  $elements['map_google_api_key'] = $this
    ->setMapGoogleApiKeyElement();

  // 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 Map Geometries Options Element.
  $this
    ->setGeometriesAdditionalOptionsElement($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);

  // Set Map Geocoder Control Element, if the Geocoder Module exists,
  // otherwise output a tip on Geocoder Module Integration.
  $this
    ->setGeocoderMapControl($elements, $settings);

  // Set Map Lazy Load Element.
  $this
    ->setMapLazyLoad($settings, $elements);
  return $elements;
}