GeolocationMapPolygon.php in Geolocation Field 8.3
File
src/Element/GeolocationMapPolygon.php
View source
<?php
namespace Drupal\geolocation\Element;
class GeolocationMapPolygon extends GeolocationMapShapeBase {
public function getInfo() {
$class = get_class($this);
return [
'#process' => [
[
$class,
'processGroup',
],
],
'#pre_render' => [
[
$class,
'preRenderGroup',
],
[
$this,
'preRenderPolygon',
],
],
'#title' => NULL,
'#coordinates' => NULL,
'#id' => NULL,
'#stroke_color' => NULL,
'#stroke_width' => NULL,
'#stroke_opacity' => NULL,
'#fill_color' => NULL,
'#fill_opacity' => NULL,
];
}
public function preRenderPolygon(array $render_array) {
$render_array = parent::preRenderGeolocationShape($render_array);
$render_array['#theme'] = 'geolocation_map_polygon';
$render_array['#attributes']
->addClass('geolocation-polygon');
if (!empty($render_array['#fill_color'])) {
$render_array['#attributes']
->setAttribute('data-fill-color', $render_array['#fill_color']);
}
if (!empty($render_array['#fill_opacity'])) {
$render_array['#attributes']
->setAttribute('data-fill-opacity', (double) $render_array['#fill_opacity']);
}
return $render_array;
}
}