public function CustomIconThemer::buildMapThemerElement in Geofield Map 8.2
Provides a Map Themer Options Element.
Parameters
array $defaults: The default values/settings.
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
\Drupal\geofield_map\Plugin\views\style\GeofieldGoogleMapViewStyle $geofieldMapView: The Geofield Map View display object.
Return value
array The Map Themer Options Element
Overrides MapThemerInterface::buildMapThemerElement
File
- src/
Plugin/ GeofieldMapThemer/ CustomIconThemer.php, line 42
Class
- CustomIconThemer
- Style plugin to render a View output as a Leaflet map.
Namespace
Drupal\geofield_map\Plugin\GeofieldMapThemerCode
public function buildMapThemerElement(array $defaults, array &$form, FormStateInterface $form_state, GeofieldGoogleMapViewStyle $geofieldMapView) {
// Get the existing (Default) Element settings.
$default_element = $this
->getDefaultThemerElement($defaults);
$file_upload_help = $this->markerIcon
->getFileUploadHelp();
$fid = (int) (!empty($default_element['icon_file']['fids'])) ? $default_element['icon_file']['fids'] : NULL;
$element = [
'#markup' => Markup::create($this
->t('<label>Custom Icon Image File</label>')),
'#type' => 'container',
'description' => [
'#markup' => Markup::create($this
->t('The chosen icon file will be used as Marker for all Geofield Map features @file_upload_help', [
'@file_upload_help' => $this->renderer
->renderPlain($file_upload_help),
])),
],
'icon_file' => $this->markerIcon
->getIconFileManagedElement($fid[0]),
'image_style' => [
'#type' => 'select',
'#title' => $this
->t('Image style'),
'#options' => $this->markerIcon
->getImageStyleOptions(),
'#default_value' => isset($default_element['image_style']) ? $default_element['image_style'] : 'geofield_map_default_icon_style',
'#states' => [
'visible' => [
':input[name="style_options[map_marker_and_infowindow][theming][geofieldmap_custom_icon][values][icon_file][is_svg]"]' => [
'checked' => FALSE,
],
],
],
],
'image_style_svg' => [
'#type' => 'container',
'warning' => [
'#markup' => $this
->t("Image style cannot apply to SVG Files,<br>SVG natural dimension will be applied."),
],
'#states' => [
'invisible' => [
':input[name="style_options[map_marker_and_infowindow][theming][geofieldmap_custom_icon][values][icon_file][is_svg]"]' => [
'checked' => FALSE,
],
],
],
],
'label_alias' => [
'#type' => 'textfield',
'#title' => $this
->t('Label alias'),
'#default_value' => isset($default_element['label_alias']) ? $default_element['label_alias'] : '',
'#description' => $this
->t('If not empty, this will be used in the legend.'),
'#size' => 20,
],
];
return $element;
}