class GeolocationGoogleMapInput in Geolocation Field 8
Provides a one-line text field form element.
Plugin annotation
@FormElement("geolocation_google_map_input");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\Core\Render\Element\RenderElement implements ElementInterface
- class \Drupal\geolocation\Element\GeolocationGoogleMap uses GoogleMapsDisplayTrait
- class \Drupal\geolocation\Element\GeolocationGoogleMapInput implements FormElementInterface
- class \Drupal\geolocation\Element\GeolocationGoogleMap uses GoogleMapsDisplayTrait
- class \Drupal\Core\Render\Element\RenderElement implements ElementInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of GeolocationGoogleMapInput
1 #type use of GeolocationGoogleMapInput
- DemoFormElement::buildForm in modules/
geolocation_demo/ src/ Form/ DemoFormElement.php - Form constructor.
File
- src/
Element/ GeolocationGoogleMapInput.php, line 13
Namespace
Drupal\geolocation\ElementView source
class GeolocationGoogleMapInput extends GeolocationGoogleMap implements FormElementInterface {
/**
* {@inheritdoc}
*/
public function getInfo() {
$get_info = parent::getInfo();
unset($get_info['#pre_render']);
$get_info['#input'] = TRUE;
$get_info['#max_locations'] = 1;
$get_info['#process'] = [
[
$this,
'processMapInputElement',
],
];
$get_info['#theme_wrappers'] = [
'container',
];
$get_info['#attributes']['class'] = [
'geolocation-google-map-form-element',
];
$get_info['#attached']['library'] = [
'geolocation/geolocation.google_map_form_element',
];
return $get_info;
}
/**
* {@inheritdoc}
*/
public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
return $input;
}
/**
* Mapping input.
*
* @param array $element
* Element.
*
* @return array
* Renderable form element.
*/
public function processMapInputElement(array &$element) {
$element['#tree'] = TRUE;
$max_locations = 1;
if (!empty($element['#max_locations'])) {
$max_locations = (int) $element['#max_locations'];
}
if (!empty($element['#locations'])) {
$element['#locations'] = array_splice($element['#locations'], 0, $max_locations);
}
$element['geolocation_map'] = $this
->preRenderGoogleMapElement($element);
$element['#theme_wrappers']['container']['#attributes']['id'] = 'geolocation-google-map-form-element-' . $element['geolocation_map']['#uniqueid'];
$element['#attached']['drupalSettings'] = [
'geolocation' => [
'googleMapFormElements' => [
$element['geolocation_map']['#uniqueid'] => [
'maxLocations' => $max_locations,
],
],
],
];
for ($i = 0; $i < $max_locations; $i++) {
$element['geolocation_map_input_' . $i] = [
'#type' => 'fieldset',
'#attributes' => [
'class' => [
'geolocation-map-input',
'geolocation-map-input-' . $i,
],
],
'latitude' => [
'#type' => 'textfield',
'#title' => $this
->t('Latitude'),
'#attributes' => [
'class' => [
'geolocation-map-input-latitude',
],
],
'#value' => empty($element['#locations'][$i]) ? '' : $element['#locations'][$i]['latitude'],
],
'longitude' => [
'#type' => 'textfield',
'#title' => $this
->t('Longitude'),
'#attributes' => [
'class' => [
'geolocation-map-input-longitude',
],
],
'#value' => empty($element['#locations'][$i]) ? '' : $element['#locations'][$i]['longitude'],
],
];
if (!empty($element['#title'])) {
if ($max_locations > 1) {
$element['geolocation_map_input_' . $i]['#title'] = $element['#title'] . ' #' . $i;
}
else {
$element['geolocation_map_input_' . $i]['#title'] = $element['#title'];
}
}
}
return $element;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
GeolocationGoogleMap:: |
public | function | Map element. | |
GeolocationGoogleMapInput:: |
public | function |
Returns the element properties for this element. Overrides GeolocationGoogleMap:: |
|
GeolocationGoogleMapInput:: |
public | function | Mapping input. | |
GeolocationGoogleMapInput:: |
public static | function |
Determines how user input is mapped to an element's #value property. Overrides FormElementInterface:: |
|
GoogleMapsDisplayTrait:: |
public static | property | Google maps url with default parameters. | |
GoogleMapsDisplayTrait:: |
public static | property | Google map style - Hybrid. | |
GoogleMapsDisplayTrait:: |
public static | property | Google map max zoom level. | |
GoogleMapsDisplayTrait:: |
public static | property | Google map min zoom level. | |
GoogleMapsDisplayTrait:: |
public static | property | Google map style - Roadmap. | |
GoogleMapsDisplayTrait:: |
public static | property | Google map style - Satellite. | |
GoogleMapsDisplayTrait:: |
public static | property | Google map style - Terrain. | |
GoogleMapsDisplayTrait:: |
public static | function | Provide a populated settings array. | |
GoogleMapsDisplayTrait:: |
public | function | Return all module and custom defined parameters. | |
GoogleMapsDisplayTrait:: |
public | function | Return the fully build URL to load Google Maps API. | |
GoogleMapsDisplayTrait:: |
public | function | Provide settings ready to handover to JS to feed to Google Maps. | |
GoogleMapsDisplayTrait:: |
public | function | Provide a generic map settings form array. | |
GoogleMapsDisplayTrait:: |
public | function | Provide a summary array to use in field formatters. | |
GoogleMapsDisplayTrait:: |
private | function | An array of all available map types. | |
GoogleMapsDisplayTrait:: |
public | function | Validate the form elements defined above. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
RenderElement:: |
public static | function | Adds Ajax information about an element to communicate with JavaScript. | |
RenderElement:: |
public static | function | Adds members of this group as actual elements for rendering. | |
RenderElement:: |
public static | function | Form element processing handler for the #ajax form property. | 1 |
RenderElement:: |
public static | function | Arranges elements into groups. | |
RenderElement:: |
public static | function |
Sets a form element's class attribute. Overrides ElementInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |