public function CustomIconThemer::getLegend in Geofield Map 8.2
Generate the Legend render array.
Parameters
array $map_theming_values: The Map themer mapping values.
array $configuration: The legend block configuration array.
Return value
mixed The icon definition.
Overrides MapThemerInterface::getLegend
File
- src/
Plugin/ GeofieldMapThemer/ CustomIconThemer.php, line 108
Class
- CustomIconThemer
- Style plugin to render a View output as a Leaflet map.
Namespace
Drupal\geofield_map\Plugin\GeofieldMapThemerCode
public function getLegend(array $map_theming_values, array $configuration = []) {
$legend = $this
->defaultLegendHeader($configuration);
// Get the icon image style, as result of the Legend configuration.
$image_style = isset($configuration['markers_image_style']) ? $configuration['markers_image_style'] : 'none';
// Get the map_theming_image_style, is so set.
if (isset($configuration['markers_image_style']) && $configuration['markers_image_style'] == '_map_theming_image_style_') {
$image_style = isset($map_theming_values['image_style']) ? $map_theming_values['image_style'] : 'none';
}
$fid = (int) (!empty($map_theming_values['icon_file']['fids'])) ? $map_theming_values['icon_file']['fids'][0] : NULL;
$legend['table']['custom-icon'] = [
'value' => [
'#type' => 'container',
'label' => [
'#markup' => !empty($map_theming_values['label_alias']) ? $map_theming_values['label_alias'] : $this
->t('All Markers'),
],
'#attributes' => [
'class' => [
'value',
],
],
],
'marker' => [
'#type' => 'container',
'icon_file' => !empty($fid) ? $this->markerIcon
->getLegendIconFromFid($fid, $image_style) : $this
->getDefaultLegendIcon(),
'#attributes' => [
'class' => [
'marker',
],
],
],
];
$legend['notes'] = [
'#markup' => isset($configuration['legend_notes']) ? $configuration['legend_notes'] : '',
'#attributes' => [
'class' => [
'notes',
],
],
];
return $legend;
}