class Here in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 modules/geolocation_here/src/Plugin/geolocation/MapProvider/Here.php \Drupal\geolocation_here\Plugin\geolocation\MapProvider\Here
Provides HERE Maps API.
Plugin annotation
@MapProvider(
id = "here",
name = @Translation("HERE Maps"),
description = @Translation("Here support."),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\geolocation\MapProviderBase implements ContainerFactoryPluginInterface, MapProviderInterface
- class \Drupal\geolocation_here\Plugin\geolocation\MapProvider\Here
- class \Drupal\geolocation\MapProviderBase implements ContainerFactoryPluginInterface, MapProviderInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of Here
File
- modules/
geolocation_here/ src/ Plugin/ geolocation/ MapProvider/ Here.php, line 17
Namespace
Drupal\geolocation_here\Plugin\geolocation\MapProviderView source
class Here extends MapProviderBase {
/**
* {@inheritdoc}
*/
public static function getDefaultSettings() {
return array_replace_recursive(parent::getDefaultSettings(), [
'zoom' => 10,
'height' => '400px',
'width' => '100%',
]);
}
/**
* {@inheritdoc}
*/
public function getSettings(array $settings) {
$settings = parent::getSettings($settings);
$settings['zoom'] = (int) $settings['zoom'];
return $settings;
}
/**
* {@inheritdoc}
*/
public function getSettingsSummary(array $settings) {
$settings = array_replace_recursive(self::getDefaultSettings(), $settings);
$summary = parent::getSettingsSummary($settings);
$summary[] = $this
->t('Zoom level: @zoom', [
'@zoom' => $settings['zoom'],
]);
$summary[] = $this
->t('Height: @height', [
'@height' => $settings['height'],
]);
$summary[] = $this
->t('Width: @width', [
'@width' => $settings['width'],
]);
return $summary;
}
/**
* {@inheritdoc}
*/
public function getSettingsForm(array $settings, array $parents = []) {
$settings += self::getDefaultSettings();
if ($parents) {
$parents_string = implode('][', $parents);
}
else {
$parents_string = NULL;
}
$form = parent::getSettingsForm($settings, $parents);
$form['height'] = [
'#group' => $parents_string,
'#type' => 'textfield',
'#title' => $this
->t('Height'),
'#description' => $this
->t('Enter the dimensions and the measurement units. E.g. 200px or 100%.'),
'#size' => 4,
'#default_value' => $settings['height'],
];
$form['width'] = [
'#group' => $parents_string,
'#type' => 'textfield',
'#title' => $this
->t('Width'),
'#description' => $this
->t('Enter the dimensions and the measurement units. E.g. 200px or 100%.'),
'#size' => 4,
'#default_value' => $settings['width'],
];
$form['zoom'] = [
'#group' => $parents_string,
'#type' => 'select',
'#title' => $this
->t('Zoom level'),
'#options' => range(0, 20),
'#description' => $this
->t('The initial resolution at which to display the map, where zoom 0 corresponds to a map of the Earth fully zoomed out, and higher zoom levels zoom in at a higher resolution.'),
'#default_value' => $settings['zoom'],
'#process' => [
[
'\\Drupal\\Core\\Render\\Element\\RenderElement',
'processGroup',
],
[
'\\Drupal\\Core\\Render\\Element\\Select',
'processSelect',
],
],
'#pre_render' => [
[
'\\Drupal\\Core\\Render\\Element\\RenderElement',
'preRenderGroup',
],
],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function alterRenderArray(array $render_array, array $map_settings, array $context = []) {
$config = \Drupal::config('here_maps.settings');
$map_settings = $this
->getSettings($map_settings);
$render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
'library' => [
'geolocation_here/geolocation.here',
],
'drupalSettings' => [
'geolocation' => [
'hereMapsAppId' => $config
->get('app_id'),
'hereMapsAppCode' => $config
->get('app_code'),
'maps' => [
$render_array['#id'] => [
'settings' => [
'here_settings' => $map_settings,
],
],
],
],
],
]);
$render_array = parent::alterRenderArray($render_array, $map_settings, $context);
return $render_array;
}
/**
* {@inheritdoc}
*/
public static function getControlPositions() {
return [
'topleft' => t('Top left'),
'topright' => t('Top right'),
'bottomleft' => t('Bottom left'),
'bottomright' => t('Bottom right'),
];
}
/**
* {@inheritdoc}
*/
public function alterCommonMap(array $render_array, array $map_settings, array $context) {
$render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
'library' => [
'geolocation_here/commonmap.here',
],
]);
return $render_array;
}
}
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 | |
Here:: |
public | function |
Alter common map build array. Overrides MapProviderBase:: |
|
Here:: |
public | function |
Alter render array. Overrides MapProviderBase:: |
|
Here:: |
public static | function |
Return available control positions. Overrides MapProviderBase:: |
|
Here:: |
public static | function |
Provide a populated settings array. Overrides MapProviderBase:: |
|
Here:: |
public | function |
Provide map provider specific settings ready to handover to JS. Overrides MapProviderBase:: |
|
Here:: |
public | function |
Provide a generic map settings form array. Overrides MapProviderBase:: |
|
Here:: |
public | function |
Provide a summary array to use in field formatters. Overrides MapProviderBase:: |
|
MapProviderBase:: |
protected | property | Map feature manager. | |
MapProviderBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
MapProviderBase:: |
public | function | Validate form. | |
MapProviderBase:: |
public | function |
Constructs a new GeocoderBase object. Overrides PluginBase:: |
|
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. | |
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. |